mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix bug with renames when there are dropdown conditions and some columns have null widgetOptions
Summary: Error manifests as "Application Error: [Sandbox] TypeError the JSON object must be str, bytes or bytearray, not NoneType" Test Plan: Added a test case. Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D4347
This commit is contained in:
parent
d22d7a4ac8
commit
99d0b9db78
@ -30,6 +30,8 @@ def perform_dropdown_condition_renames(useractions, renames):
|
||||
updates = []
|
||||
|
||||
for col in useractions.get_docmodel().columns.all:
|
||||
if not col.widgetOptions:
|
||||
continue
|
||||
|
||||
# Find all columns in the document that have dropdown conditions.
|
||||
try:
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=line-too-long
|
||||
|
||||
import json
|
||||
|
||||
@ -156,3 +157,28 @@ class TestDCRenames(test_engine.EngineTestCase):
|
||||
[27, 2, "features", build_dc2("identifier", "address")],
|
||||
])
|
||||
self.assert_invalid_formula_untouched()
|
||||
|
||||
def test_rename_when_null_widget_options(self):
|
||||
# Create a column with None for widget options. Just a presence of such a column was causing
|
||||
# an error at one point.
|
||||
self.engine.apply_user_actions([useractions.from_repr(ua) for ua in (
|
||||
["AddColumn", "Schools", "dummy", {
|
||||
"type": "Text",
|
||||
"widgetOptions": None,
|
||||
}],
|
||||
)])
|
||||
|
||||
# Check that rename works when it needs to affect a dropdown condition.
|
||||
# First check the dropdown condition before the rename.
|
||||
self.assertTableData("_grist_Tables_column", cols="subset", rows="subset", data=[
|
||||
["id", "parentId", "colId", "widgetOptions"],
|
||||
[12, 2, "address", build_dc1("name", "city")],
|
||||
])
|
||||
|
||||
self.apply_user_action(["RenameColumn", "Address", "city", "area"])
|
||||
|
||||
# Check the condition got updated after the rename.
|
||||
self.assertTableData("_grist_Tables_column", cols="subset", rows="subset", data=[
|
||||
["id", "parentId", "colId", "widgetOptions"],
|
||||
[12, 2, "address", build_dc1("name", "area")],
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user