(core) When checking for metadata consistency, check for stray column records too

Summary:
Currently, an undo of a non-last action can leave the doc in an inconsistent
state. For example, it may remove a table, but fail to remove all columns of
it from metadata. We normally check that schema corresponds to metadata, but
stray columns were not visible to this check, and instead caused later table
additions to fail.

This diff fixes the check to fail the action that causes stray columns, and
to restore the doc to a consistent state.

Note that this only handles schema-metadata inconsistencies, but an undo of a
non-last action can easily create other surprises.

Test Plan: Added a test case that triggered inconsistency before, and now triggers a failed undo.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2715
This commit is contained in:
Dmitry S
2021-01-27 14:38:12 -05:00
parent b5c1fc0c1a
commit 14cdd47675
4 changed files with 71 additions and 3 deletions

View File

@@ -199,8 +199,8 @@ export class GristDoc extends DisposableWithEvents {
/* Command binding */
this.autoDispose(commands.createGroup({
undo() { this._undoStack.sendUndoAction(); },
redo() { this._undoStack.sendRedoAction(); },
undo() { this._undoStack.sendUndoAction().catch(reportError); },
redo() { this._undoStack.sendRedoAction().catch(reportError); },
reloadPlugins() { this.docComm.reloadPlugins().then(() => G.window.location.reload(false)); },
}, this, true));