mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix error when updating summary table formulas after rename
Summary: Formulas in summary tables were being associated with the source table for automatic updating. When a table/column was renamed such that the formula needed to update to match, it would look for a column with the same colId but in the source table. Such a column might not exist which would lead to an error, or if it existed then the update would be wrong. This association was created while building formulas to display in the code view in a nested `_Summary` class, it didn't need to exist at all. So this diff simply prevents the association from being created. User report and discussion: https://grist.slack.com/archives/C0234CPPXPA/p1659717322297019 Test Plan: Extended `TestSummary.test_table_rename` Python test. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3568
This commit is contained in:
@@ -529,6 +529,13 @@ class Address:
|
||||
[2, "Address_summary_city_state", 1],
|
||||
])
|
||||
|
||||
# Add a column to the summary table with a name that doesn't exist in the source table,
|
||||
# to test a specific bug fix.
|
||||
self.add_column(
|
||||
"Address_summary_city_state", "lookup",
|
||||
formula="Address.lookupRecords(city=$city)", isFormula=True
|
||||
)
|
||||
|
||||
# Rename the table: this is what we are really testing in this test case.
|
||||
self.apply_user_action(["RenameTable", "Address", "Location"])
|
||||
|
||||
@@ -537,6 +544,14 @@ class Address:
|
||||
[2, "Location_summary_city_state", 1],
|
||||
])
|
||||
|
||||
# Check that the summary table column's formula was updated correctly.
|
||||
self.assertTableData("_grist_Tables_column", cols="subset", rows="subset", data=[
|
||||
["id", "colId", "formula"],
|
||||
[19, "lookup", "Location.lookupRecords(city=$city)"],
|
||||
])
|
||||
# This column isn't expected in _do_test_updates().
|
||||
self.remove_column("Location_summary_city_state", "lookup")
|
||||
|
||||
# Verify that the bigger summary table respects all updates to the renamed source table.
|
||||
self._do_test_updates("Location", "Location_summary_city_state")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user