From 89e1a4af108a9228c60ae8dc6e32ce93767e65f1 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Mon, 20 Nov 2023 20:21:30 +0200 Subject: [PATCH] (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 --- sandbox/grist/testscript.json | 4 ++-- sandbox/grist/useractions.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sandbox/grist/testscript.json b/sandbox/grist/testscript.json index 65774ca3..f911001a 100644 --- a/sandbox/grist/testscript.json +++ b/sandbox/grist/testscript.json @@ -2382,8 +2382,8 @@ "ACTIONS": { "stored": [ ["BulkRemoveRecord", "_grist_Views_section", [1, 2, 3]], - ["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 0}], ["UpdateRecord", "_grist_Tables", 4, {"rawViewSectionRef": 0}], + ["UpdateRecord", "_grist_Tables", 4, {"recordCardViewSectionRef": 0}], ["RemoveRecord", "_grist_TabBar", 1], ["RemoveRecord", "_grist_Pages", 1], ["RemoveRecord", "_grist_Views", 1], @@ -2397,8 +2397,8 @@ ["BulkAddRecord", "_grist_Views_section", [1, 2, 3], {"borderWidth": [1, 1, 1], "defaultWidth": [100, 100, 100], "parentId": [1, 0, 0], "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, {"recordCardViewSectionRef": 3}], ["AddRecord", "_grist_TabBar", 1, {"tabPos": 1.0, "viewRef": 1}], ["AddRecord", "_grist_Pages", 1, {"pagePos": 1.0, "viewRef": 1}], ["AddRecord", "_grist_Views", 1, {"name": "Foo", "type": "raw_data"}], diff --git a/sandbox/grist/useractions.py b/sandbox/grist/useractions.py index 5acc2c55..0f56dbcb 100644 --- a/sandbox/grist/useractions.py +++ b/sandbox/grist/useractions.py @@ -1072,7 +1072,7 @@ class UserActions(object): # Also remove any references to this row from other tables. 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): continue updates = ref_col.get_updates_for_removed_target_rows(row_id_set)