refactor(datagrid): restore reloadVersion external-only semantic + invalidate schema cache#1289
Merged
Merged
Conversation
…invalidate schema cache on refresh
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two follow-ups from PR #1288 (fix #1281). Independent of #1288 — lands cleanly before or after.
reloadVersionwas overloaded → cell-edit perf regression after #1288ChangeManaging.reloadVersionwas originally a signal for "external data identity reloaded; column widths may need recalc". Two grid delegates explicitly document this and route cell-edit visual updates through their ownreloadAllVisibleRows()path (StructureGridDelegate.swift:316-319,CreateTableGridDelegate.swift:20-24). The architects clearly knew the snapshot wouldn't catch cell-content updates.Over time, 26+ bump sites accumulated — most on internal mutations (cell edit, add row, undo, redo). They were no-ops because nothing observed the counter. When PR #1288 wired the counter into
DataGridUpdateSnapshotto fix the external-refresh bug, those internal bumps started cascading into fulltableView.reloadData()calls on top of the precise reloads already issued byCellCommit. On Data tab, Tab-through editing a wide table now stacks one full reload per cell.This PR restores the original semantic by removing 22 bumps from internal mutation paths:
StructureChangeManager.swift: keeps bumps atloadSchema(line 107) anddiscardChanges(line 513). Removes 13 bumps from add/edit/delete/undo of column, index, FK.DataChangeManager.swift: keeps bumps atclearChanges(82),configureForTable(107),discardChanges(470). Removes 9 bumps fromrecordCellChange,recordRowDeletion,recordRowInsertion, undo handlers.Targeted reload paths already cover every removed site:
DataGridView+CellCommit.swift:46-59(precisereloadData(forRowIndexes:columnIndexes:))StructureGridDelegate.dataGridDeleteRows→reloadAllVisibleRows()(already documented at line 169-172)dataGridUndo/dataGridRedo→reloadAllVisibleRows()@Observablere-eval → snapshotrowDisplayCountchanges → existingstructureChangedpath → full reloadAutocomplete shows stale columns after external rename
SQLSchemaProvider.columnCache(LRU keyed by lowercase table name) is only invalidated on database switch viaMainContentCoordinator.reconcilePostSchemaLoad(). Nothing clears it on Refresh, so after externalALTER TABLE RENAME COLUMN+ ⌘R, query-editor autocomplete keeps suggesting the old column name.Fix:
SQLSchemaProvider.clearColumnCache()actor method (cancels eager load, clears cache + access order, restarts eager load if a driver is cached).SchemaProviderRegistrysubscribes toAppCommands.shared.refreshDataininit(). On signal, routes throughinvalidateColumnCache(for connectionId: UUID?). Scoped to one connection if signal carries an ID; otherwise invalidates every loaded provider. Matches the existingrefreshDataconvention used byImportDialog(scoped) vs toolbar refresh (broad).Test plan
ALTER TABLE RENAME COLUMN a TO b→ ⌘R on Structure tab → Columns sub-tab showsbimmediately.SELECT * FROM test_refresh WHERE, trigger autocomplete on column prefix → sees current name. Externally rename column → ⌘R → trigger autocomplete on same prefix → sees new name.