(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

@@ -34,6 +34,11 @@ class DocActions(object):
def BulkRemoveRecord(self, table_id, row_ids):
table = self._engine.tables[table_id]
# Ignore records that don't exist in the table.
row_ids = [r for r in row_ids if r in table.row_ids]
if not row_ids:
return
# Collect the undo values, and unset all values in the column (i.e. set to defaults), just to
# make sure we don't have stale values hanging around.
undo_values = {}