Skip to content

fix(mssql, oracle): enable schema switching from Cmd+K quick switcher#1050

Merged
datlechin merged 2 commits intomainfrom
fix/mssql-oracle-schema-switching
May 6, 2026
Merged

fix(mssql, oracle): enable schema switching from Cmd+K quick switcher#1050
datlechin merged 2 commits intomainfrom
fix/mssql-oracle-schema-switching

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • Bug — picking a schema (e.g. rpt) from Cmd+K Quick Switcher on a SQL Server or Oracle connection silently did nothing. Schemas appeared in the search list, selection was a no-op, and there was no log or alert. Reported in r/macapps feedback by Pedro_Prevost.
  • Root cause — three layers were misaligned:
    1. QuickSwitcherViewModel had a hardcoded list [.postgresql, .redshift, .oracle, .mssql] that gated fetchSchemas(), so schemas appeared as searchable items.
    2. PluginMetadataRegistry+RegistryDefaults had supportsSchemaSwitching: false for SQL Server and Oracle, and the matching plugin sources (MSSQLPlugin.swift, OraclePlugin.swift) inherited the default false from the DriverPlugin extension.
    3. MainContentCoordinator+Navigation.switchSchema(to:) had guard PluginManager.shared.supportsSchemaSwitching(for: connection.type) else { return } — a silent early-return with no log, no alert, no user feedback.
  • Fix is plumbing-only. The MSSQL and Oracle plugin drivers already implemented switchSchema(to:) correctly (MSSQL updates _currentSchema for the table-listing filter; Oracle runs ALTER SESSION SET CURRENT_SCHEMA), and FakeMSSQLPlugin in tests already had supportsSchemaSwitching = true — i.e. the bug was test/prod divergence, not missing implementation.

What changes

  • MSSQLPlugin.swift — add supportsSchemaSwitching = true, append .selectSchemaFromLastSession to postConnectActions so the chosen schema persists across reconnects.
  • OraclePlugin.swift — same.
  • PluginMetadataRegistry+RegistryDefaults.swift — flip supportsSchemaSwitching: true for both SQL Server and Oracle, and align postConnectActions so the registry default matches what the plugin reports (defense in depth: the plugin metadata wins via PluginManager+Registration, but the registry default is what's served before the plugin loads).
  • QuickSwitcherViewModel.swift — drop the hardcoded [postgresql, redshift, oracle, mssql] list, derive the gate from PluginManager.shared.supportsSchemaSwitching(for:) so future engines pick up the correct behavior automatically.
  • MainContentCoordinator+Navigation.swift — replace the silent guard with a navigationLogger.warning and a "Schema Switching Not Supported" alert, so future regressions surface visibly instead of as a dead Cmd+K shortcut. After this PR the guard should be unreachable for MSSQL/Oracle, but the alert path is the safety net for any other engine that ever appears in the Quick Switcher schema list without supporting the switch.
  • PluginMetadataRegistrySchemaSwitchingTests.swift (new) — regression tests asserting supportsSchemaSwitching == true for SQL Server, Oracle, and PostgreSQL; false for MySQL and SQLite; selectSchemaFromLastSession is in postConnectActions for the schema-aware engines; and a cross-component consistency test that lists every engine the Quick Switcher claims is schema-aware and asserts the registry agrees. Without this test the next regression of the same shape would slip through.

Test plan

  • Connect to a SQL Server with multiple schemas (dbo, rpt, etc.). Press ⌘K, search for rpt, hit Enter. The schema switches: sidebar refreshes to that schema's tables, toolbar reflects the switch, no silent no-op.
  • Reconnect. The previously chosen schema is restored (selectSchemaFromLastSession).
  • Same flow for Oracle: ⌘K → schema name → confirms ALTER SESSION SET CURRENT_SCHEMA ran (sidebar refreshes).
  • Same flow for PostgreSQL (regression check — should still work).
  • On MySQL/SQLite (no schema concept), verify ⌘K does not show schemas (the if PluginManager.shared.supportsSchemaSwitching(for:) gate filters them out at fetch time).
  • If switchSchema(to:) is somehow called for an unsupported type (URL deeplink, programmatic call), the alert "Schema Switching Not Supported" surfaces instead of silent return.
  • Run swiftlint lint --strict TableProTests/Core/Plugins/PluginMetadataRegistrySchemaSwitchingTests.swift (already passing).
  • Run the full test target via Xcode; new tests in PluginMetadataRegistrySchemaSwitchingTests should pass.

datlechin added 2 commits May 6, 2026 23:02
Also pin plugin-level supportsSchemaSwitching = true for MSSQL and Oracle so plugin metadata, registry default, and Quick Switcher allowlist all agree.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 8dbf970 into main May 6, 2026
2 checks passed
@datlechin datlechin deleted the fix/mssql-oracle-schema-switching branch May 6, 2026 16:10
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