mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Use GristObjCode in CellValue
Summary: Makes type checking a bit stronger Test Plan: it just has to compile Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3065
This commit is contained in:
@@ -13,6 +13,7 @@ import {BulkColValues, DocAction, TableColValues, TableDataAction, toTableDataAc
|
||||
import * as gristTypes from 'app/common/gristTypes';
|
||||
import * as marshal from 'app/common/marshal';
|
||||
import * as schema from 'app/common/schema';
|
||||
import {GristObjCode} from "app/plugin/GristData";
|
||||
import {ActionHistoryImpl} from 'app/server/lib/ActionHistoryImpl';
|
||||
import {ExpandedQuery} from 'app/server/lib/ExpandedQuery';
|
||||
import {IDocStorageManager} from 'app/server/lib/IDocStorageManager';
|
||||
@@ -35,7 +36,7 @@ const debuglog = util.debuglog('db');
|
||||
|
||||
const maxSQLiteVariables = 500; // Actually could be 999, so this is playing it safe.
|
||||
|
||||
const PENDING_VALUE = [gristTypes.GristObjCode.Pending];
|
||||
const PENDING_VALUE = [GristObjCode.Pending];
|
||||
|
||||
export class DocStorage implements ISQLiteDB {
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {ServerQuery} from 'app/common/ActiveDocAPI';
|
||||
import {ApiError} from 'app/common/ApiError';
|
||||
import {DocData} from 'app/common/DocData';
|
||||
import {parseFormula} from 'app/common/Formula';
|
||||
import {removePrefix} from 'app/common/gutil';
|
||||
import {quoteIdent} from 'app/server/lib/SQLiteDB';
|
||||
import { ServerQuery } from 'app/common/ActiveDocAPI';
|
||||
import { ApiError } from 'app/common/ApiError';
|
||||
import { DocData } from 'app/common/DocData';
|
||||
import { parseFormula } from 'app/common/Formula';
|
||||
import { removePrefix } from 'app/common/gutil';
|
||||
import { GristObjCode } from 'app/plugin/GristData';
|
||||
import { quoteIdent } from 'app/server/lib/SQLiteDB';
|
||||
|
||||
/**
|
||||
* Represents a query for Grist data with support for SQL-based
|
||||
@@ -19,7 +20,7 @@ export interface ExpandedQuery extends ServerQuery {
|
||||
// step. That means we need to pass the error message along
|
||||
// explicitly.
|
||||
constants?: {
|
||||
[colId: string]: ['E', string] | ['P'];
|
||||
[colId: string]: [GristObjCode.Exception, string] | [GristObjCode.Pending];
|
||||
};
|
||||
|
||||
// A list of join clauses to bring in data from other tables.
|
||||
@@ -115,7 +116,7 @@ export function expandQuery(iquery: ServerQuery, docData: DocData, onDemandFormu
|
||||
// We add a trivial selection, and store errors in the query for substitution later.
|
||||
sqlFormula = '0';
|
||||
if (!query.constants) { query.constants = {}; }
|
||||
query.constants[colId] = ['E', error];
|
||||
query.constants[colId] = [GristObjCode.Exception, error];
|
||||
}
|
||||
if (sqlFormula) {
|
||||
selects.add(`${sqlFormula} as ${quoteIdent(colId)}`);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { getSetMapValue, isObject, pruneArray } from 'app/common/gutil';
|
||||
import { canEdit, canView, isValidRole, Role } from 'app/common/roles';
|
||||
import { FullUser, UserAccessData } from 'app/common/UserAPI';
|
||||
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
|
||||
import { GristObjCode } from 'app/plugin/GristData';
|
||||
import { compileAclFormula } from 'app/server/lib/ACLFormula';
|
||||
import { DocClients } from 'app/server/lib/DocClients';
|
||||
import { getDocSessionAccess, getDocSessionUser, OptDocSession } from 'app/server/lib/DocSession';
|
||||
@@ -1104,9 +1105,9 @@ export class GranularAccess implements GranularAccessForBundle {
|
||||
if (colValues === undefined) {
|
||||
censorAt = () => 1;
|
||||
} else if (Array.isArray(action[2])) {
|
||||
censorAt = (colId, idx) => (copyOnNeed() as BulkColValues)[colId][idx] = ['C']; // censored
|
||||
censorAt = (colId, idx) => (copyOnNeed() as BulkColValues)[colId][idx] = [GristObjCode.Censored];
|
||||
} else {
|
||||
censorAt = (colId) => (copyOnNeed() as ColValues)[colId] = ['C']; // censored
|
||||
censorAt = (colId) => (copyOnNeed() as ColValues)[colId] = [GristObjCode.Censored];
|
||||
}
|
||||
|
||||
// These map an index of a row in the action to its index in rowsBefore and in rowsAfter.
|
||||
|
||||
Reference in New Issue
Block a user