(core) Renaming table linked by summary table resulted in error

Summary:
When a table was selected by a summary table, renaming that table using
section widget resulted in a javascript error.

Test Plan: new test

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3475
This commit is contained in:
Jarosław Sadziński 2022-06-08 18:26:21 +02:00
parent 1c89d08ea3
commit 64d9ecacdb

View File

@ -335,7 +335,11 @@ export function getFilterFunc(docData: DocData, query: ClientQuery): RowFilterFu
* rowIds), and consistently sorted. We use that to identify a Query across table/column renames. * rowIds), and consistently sorted. We use that to identify a Query across table/column renames.
*/ */
function convertQueryToRefs(docModel: DocModel, query: ClientQuery): QueryRefs { function convertQueryToRefs(docModel: DocModel, query: ClientQuery): QueryRefs {
const tableRec: any = docModel.dataTables[query.tableId].tableMetaRow; // During table rename, we can be referencing old name of a table.
const tableRec = Object.values(docModel.dataTables).find(t => t.tableData.tableId === query.tableId)?.tableMetaRow;
if (!tableRec) {
throw new Error(`Table ${query.tableId} not found`);
}
const colRefsByColId: {[colId: string]: ColRef} = {id: 'id'}; const colRefsByColId: {[colId: string]: ColRef} = {id: 'id'};
for (const col of tableRec.columns.peek().peek()) { for (const col of tableRec.columns.peek().peek()) {