fix(admin): guard find_changed_cell against cross-table schema mismatch

When switching tables, the table-switch branch writes fresh data for the
new table, which re-fires the same callback with data_previous still
holding the old table's rows. find_changed_cell only checked row count
before diffing, so if the two tables happened to have the same number of
rows it would zip mismatched-schema dicts and report a spurious changed
cell (usually the PK column), producing a confusing red alert right after
switching tables.
This commit is contained in:
Colin Maudry
2026-07-03 14:46:12 +02:00
parent d229b58f3b
commit caf800e5e8
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -144,6 +144,10 @@ def find_changed_cell(
) -> tuple[int, str, object, object] | None:
if data_previous is None or len(data) != len(data_previous):
return None
if not data or not data_previous:
return None
if set(data[0].keys()) != set(data_previous[0].keys()):
return None
for i, (new_row, old_row) in enumerate(zip(data, data_previous)):
for col, new_val in new_row.items():
old_val = old_row.get(col)