(core) Sort table._back_references in set to fix nondeterminism in tests

Summary: Title

Test Plan: Fixed a test that was failing inconsistently

Reviewers: georgegevoian, paulfitz

Reviewed By: georgegevoian, paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D4122
This commit is contained in:
Alex Hall 2023-11-20 20:21:30 +02:00
parent cea0404a22
commit 89e1a4af10
2 changed files with 3 additions and 3 deletions

View File

@ -2382,8 +2382,8 @@
"ACTIONS": { "ACTIONS": {
"stored": [ "stored": [
["BulkRemoveRecord", "_grist_Views_section", [1, 2, 3]], ["BulkRemoveRecord", "_grist_Views_section", [1, 2, 3]],
["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 0}],
["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 0}], ["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 0}],
["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 0}],
["RemoveRecord", "_grist_TabBar", 1], ["RemoveRecord", "_grist_TabBar", 1],
["RemoveRecord", "_grist_Pages", 1], ["RemoveRecord", "_grist_Pages", 1],
["RemoveRecord", "_grist_Views", 1], ["RemoveRecord", "_grist_Views", 1],
@ -2397,8 +2397,8 @@
["BulkAddRecord", "_grist_Views_section", [1, 2, 3], ["BulkAddRecord", "_grist_Views_section", [1, 2, 3],
{"borderWidth": [1, 1, 1], "defaultWidth": [100, 100, 100], "parentId": [1, 0, 0], {"borderWidth": [1, 1, 1], "defaultWidth": [100, 100, 100], "parentId": [1, 0, 0],
"parentKey": ["record", "record", "single"], "sortColRefs": ["[]", "", ""], "tableRef": [4, 4, 4]}], "parentKey": ["record", "record", "single"], "sortColRefs": ["[]", "", ""], "tableRef": [4, 4, 4]}],
["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 3}],
["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 2}], ["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 2}],
["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 3}],
["AddRecord", "_grist_TabBar", 1, {"tabPos": 1.0, "viewRef": 1}], ["AddRecord", "_grist_TabBar", 1, {"tabPos": 1.0, "viewRef": 1}],
["AddRecord", "_grist_Pages", 1, {"pagePos": 1.0, "viewRef": 1}], ["AddRecord", "_grist_Pages", 1, {"pagePos": 1.0, "viewRef": 1}],
["AddRecord", "_grist_Views", 1, {"name": "Foo", "type": "raw_data"}], ["AddRecord", "_grist_Views", 1, {"name": "Foo", "type": "raw_data"}],

View File

@ -1072,7 +1072,7 @@ class UserActions(object):
# Also remove any references to this row from other tables. # Also remove any references to this row from other tables.
row_id_set = set(row_ids) row_id_set = set(row_ids)
for ref_col in table._back_references: for ref_col in sorted(table._back_references, key=lambda c: c.node):
if ref_col.is_formula() or not isinstance(ref_col, column.BaseReferenceColumn): if ref_col.is_formula() or not isinstance(ref_col, column.BaseReferenceColumn):
continue continue
updates = ref_col.get_updates_for_removed_target_rows(row_id_set) updates = ref_col.get_updates_for_removed_target_rows(row_id_set)