Skip to content

feat(datagrid): omit hidden columns from the table browse query#1375

Merged
datlechin merged 4 commits into
mainfrom
feat/per-table-fetched-columns
May 21, 2026
Merged

feat(datagrid): omit hidden columns from the table browse query#1375
datlechin merged 4 commits into
mainfrom
feat/per-table-fetched-columns

Conversation

@datlechin

@datlechin datlechin commented May 21, 2026

Copy link
Copy Markdown
Member

Feature

Requested: choose per table which columns to load before fetch, so a table with one heavy column opens fast.

Built on the existing per-table column visibility (you asked "why not based on column visibility?" — agreed, it's cleaner). Hiding a column now also leaves it out of the browse query, so it isn't fetched. This is a clean narrower SELECT col_a, col_c, <pk> — no truncation, no aliasing, none of the corruption risk that removed the auto-SUBSTRING in #1373.

Behavior

  • Hidden = not fetched. A hidden column is omitted from the query. Hide a heavy column → the table opens/loads faster. Reuses the existing column-visibility popover + per-table persistence.
  • Primary key is always fetched even if hidden, so row identity / editing / UPDATE keep working.
  • Toggling re-runs the query (debounced) so the change takes effect; showing a column re-fetches it.
  • Scoped at open: when a table has persisted hidden columns, the first query is already scoped (column list comes from the cached, async SQLSchemaProvider.getColumns), so re-opening is fast — no SELECT * round-trip first.
  • The visibility popover lists the full schema (not the fetched result), so an omitted column can still be toggled back on.

Trade-off (called out): hide/show is no longer a purely cosmetic instant toggle — it re-runs the query.

Implementation

  • ColumnFetchScope.selectColumns(schema:hidden:primaryKeys:) — pure, tested: full schema minus hidden, PK always kept, nil when nothing is omitted.
  • TableQueryBuilder selectColumns: projection (nilSELECT *).
  • MainContentCoordinator+ColumnFetchScope — per-table schema-column cache (from getColumns), selectColumns(for:), requeryWithColumnScope, and the full-schema list for the picker. Cache cleared on schema reload / reset.
  • Wired through FilterCoordinator (rebuild/apply/clear), the open path, and the visibility toggles.

Tests

ColumnFetchScopeTests covers the projection: drop hidden, keep order, PK-always-retained, empty schema, hide-everything-no-PK, and unknown columns. swiftlint --strict clean.

@datlechin datlechin marked this pull request as ready for review May 21, 2026 16:42
@datlechin datlechin changed the title feat(datagrid): per-table column fetch selection (WIP foundation) feat(datagrid): omit hidden columns from the table browse query May 21, 2026
@datlechin datlechin merged commit c9b67fb into main May 21, 2026
1 check passed
@datlechin datlechin deleted the feat/per-table-fetched-columns branch May 21, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant