mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Migrate Attachments columns from marshalled blobs to JSON
Summary: Adds a migration in preparation for future work on tracking and deleting attachments. This includes a `_grist_Attachments.timeDeleted` column which isn't used yet, and changing the storage format of user columns of type `Attachments`. DocStorage now treats Attachments like RefList in general (since they use JSON), which also prompted a tiny bit of refactoring. Test Plan: Added a migration test case showing the change in format. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3352
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { CellValue } from "app/common/DocActions";
|
||||
import { FilterState, makeFilterState } from "app/common/FilterState";
|
||||
import { decodeObject } from "app/plugin/objtypes";
|
||||
import { isList, isRefListType } from "./gristTypes";
|
||||
import {CellValue} from "app/common/DocActions";
|
||||
import {FilterState, makeFilterState} from "app/common/FilterState";
|
||||
import {decodeObject} from "app/plugin/objtypes";
|
||||
import {isList, isListType} from "./gristTypes";
|
||||
|
||||
export type ColumnFilterFunc = (value: CellValue) => boolean;
|
||||
|
||||
@@ -13,7 +13,7 @@ export function makeFilterFunc({ include, values }: FilterState,
|
||||
// For example, a TypeError in the formula column and the string '["E","TypeError"]' would be seen as the same.
|
||||
// TODO: This narrow corner case seems acceptable for now, but may be worth revisiting.
|
||||
return (val: CellValue) => {
|
||||
if (isList(val) && (columnType === 'ChoiceList' || isRefListType(String(columnType)))) {
|
||||
if (isList(val) && columnType && isListType(columnType)) {
|
||||
const list = decodeObject(val) as unknown[];
|
||||
return list.some(item => values.has(item as any) === include);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,11 @@ export function getReferencedTableId(type: string) {
|
||||
}
|
||||
|
||||
export function isRefListType(type: string) {
|
||||
return type === "Attachments" || type.startsWith('RefList:');
|
||||
return type === "Attachments" || type?.startsWith('RefList:');
|
||||
}
|
||||
|
||||
export function isListType(type: string) {
|
||||
return type === "ChoiceList" || isRefListType(type);
|
||||
}
|
||||
|
||||
export function isFullReferencingType(type: string) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { GristObjCode } from "app/plugin/GristData";
|
||||
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const SCHEMA_VERSION = 27;
|
||||
export const SCHEMA_VERSION = 28;
|
||||
|
||||
export const schema = {
|
||||
|
||||
@@ -148,6 +148,7 @@ export const schema = {
|
||||
fileSize : "Int",
|
||||
imageHeight : "Int",
|
||||
imageWidth : "Int",
|
||||
timeDeleted : "DateTime",
|
||||
timeUploaded : "DateTime",
|
||||
},
|
||||
|
||||
@@ -338,6 +339,7 @@ export interface SchemaTypes {
|
||||
fileSize: number;
|
||||
imageHeight: number;
|
||||
imageWidth: number;
|
||||
timeDeleted: number;
|
||||
timeUploaded: number;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user