mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) When getting error details for on-demand formulas, provide an explanation
Summary: Since formula errors are typically obtained from the Python data engine, they were not returning any info for errors in on-demand tables (not loaded into the data engine). This change implements a detailed message to explain such errors, mainly to point out that on-demand table is the reason. Test Plan: Added a check to the OnDemand test that formula error details are shown. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4317
This commit is contained in:
parent
95320f3f5b
commit
5ef54b278f
@ -480,6 +480,7 @@ function _isInIdentifier(line: string, column: number) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a formula editor. Returns a Disposable that owns the editor.
|
* Open a formula editor. Returns a Disposable that owns the editor.
|
||||||
|
* This is used for the editor in the side panel.
|
||||||
*/
|
*/
|
||||||
export function openFormulaEditor(options: {
|
export function openFormulaEditor(options: {
|
||||||
gristDoc: GristDoc,
|
gristDoc: GristDoc,
|
||||||
|
@ -138,7 +138,7 @@ import {
|
|||||||
OptDocSession
|
OptDocSession
|
||||||
} from './DocSession';
|
} from './DocSession';
|
||||||
import {createAttachmentsIndex, DocStorage, REMOVE_UNUSED_ATTACHMENTS_DELAY} from './DocStorage';
|
import {createAttachmentsIndex, DocStorage, REMOVE_UNUSED_ATTACHMENTS_DELAY} from './DocStorage';
|
||||||
import {expandQuery} from './ExpandedQuery';
|
import {expandQuery, getFormulaErrorForExpandQuery} from './ExpandedQuery';
|
||||||
import {GranularAccess, GranularAccessForBundle} from './GranularAccess';
|
import {GranularAccess, GranularAccessForBundle} from './GranularAccess';
|
||||||
import {OnDemandActions} from './OnDemandActions';
|
import {OnDemandActions} from './OnDemandActions';
|
||||||
import {getLogMetaFromDocSession, getPubSubPrefix, getTelemetryMetaFromDocSession} from './serverUtils';
|
import {getLogMetaFromDocSession, getPubSubPrefix, getTelemetryMetaFromDocSession} from './serverUtils';
|
||||||
@ -1169,6 +1169,11 @@ export class ActiveDoc extends EventEmitter {
|
|||||||
this._log.info(docSession, "getFormulaError(%s, %s, %s, %s)",
|
this._log.info(docSession, "getFormulaError(%s, %s, %s, %s)",
|
||||||
docSession, tableId, colId, rowId);
|
docSession, tableId, colId, rowId);
|
||||||
await this.waitForInitialization();
|
await this.waitForInitialization();
|
||||||
|
const onDemand = this._onDemandActions.isOnDemand(tableId);
|
||||||
|
if (onDemand) {
|
||||||
|
// It's safe to use this.docData after waitForInitialization().
|
||||||
|
return getFormulaErrorForExpandQuery(this.docData!, tableId, colId);
|
||||||
|
}
|
||||||
return this._pyCall('get_formula_error', tableId, colId, rowId);
|
return this._pyCall('get_formula_error', tableId, colId, rowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ServerQuery } from 'app/common/ActiveDocAPI';
|
import { ServerQuery } from 'app/common/ActiveDocAPI';
|
||||||
import { ApiError } from 'app/common/ApiError';
|
import { ApiError } from 'app/common/ApiError';
|
||||||
|
import { CellValue } from 'app/common/DocActions';
|
||||||
import { DocData } from 'app/common/DocData';
|
import { DocData } from 'app/common/DocData';
|
||||||
import { parseFormula } from 'app/common/Formula';
|
import { parseFormula } from 'app/common/Formula';
|
||||||
import { removePrefix } from 'app/common/gutil';
|
import { removePrefix } from 'app/common/gutil';
|
||||||
@ -133,6 +134,24 @@ export function expandQuery(iquery: ServerQuery, docData: DocData, onDemandFormu
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getFormulaErrorForExpandQuery(docData: DocData, tableId: string, colId: string): CellValue {
|
||||||
|
// On-demand tables may produce several kinds of error messages, e.g. "Formula not supported" or
|
||||||
|
// "Cannot find column". We construct the full query to get the basic message for the requested
|
||||||
|
// column, then tack on the detail, which is fine to be the same for all of them.
|
||||||
|
const iquery: ServerQuery = {tableId, filters: {}};
|
||||||
|
const expanded = expandQuery(iquery, docData, true);
|
||||||
|
const constantValue = expanded.constants?.[colId];
|
||||||
|
if (constantValue?.length === 2) {
|
||||||
|
return [GristObjCode.Exception, constantValue[1],
|
||||||
|
`Not supported in on-demand tables.
|
||||||
|
|
||||||
|
This table is marked as an on-demand table. Such tables don't support most formulas. \
|
||||||
|
For proper formula support, unmark it as on-demand.
|
||||||
|
`];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a query that relates two homogeneous tables sharing a common set of columns,
|
* Build a query that relates two homogeneous tables sharing a common set of columns,
|
||||||
* returning rows that exist in both tables (if they have differences), and rows from
|
* returning rows that exist in both tables (if they have differences), and rows from
|
||||||
|
Loading…
Reference in New Issue
Block a user