(core) Fix another cause of inconsistency that can be triggered by bad DocActions.

Summary:
An incorrect DocAction (as possible from an Undo of a non-last action)
could cause RemoveRecord on an already missing record. This used to
create an invalid undo, and wreak havoc when a series of DocActions
later fails and needs to be reverted.

To fix, consider RemoveRecord of a missing record to be a no-op.

Test Plan: Includes a new test case that triggers the problem.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2717
This commit is contained in:
Dmitry S
2021-01-28 01:54:27 -05:00
parent 9fa5d4c9d6
commit ec023a3ba6
3 changed files with 36 additions and 1 deletions

View File

@@ -434,7 +434,8 @@ class Engine(object):
collist = sorted(actions.transpose_bulk_action(meta_columns),
key=lambda c: (c.parentId, c.parentPos))
raise AssertionError("Internal schema inconsistent; extra columns in metadata:\n"
+ "\n".join(' ' + str(schema.SchemaColumn(c.colId, c.type, bool(c.isFormula), c.formula))
+ "\n".join(' #%s %s' %
(c.id, schema.SchemaColumn(c.colId, c.type, bool(c.isFormula), c.formula))
for c in collist if c.parentId not in valid_table_refs))
def dump_state(self):