Skip to content

fix: persist and restore PostgreSQL schema on reconnect, fix stuck error dialog#542

Merged
datlechin merged 1 commit intomainfrom
fix/schema-persistence-and-alert-dismiss
Mar 31, 2026
Merged

fix: persist and restore PostgreSQL schema on reconnect, fix stuck error dialog#542
datlechin merged 1 commit intomainfrom
fix/schema-persistence-and-alert-dismiss

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Fixes #540 — two critical bugs when reconnecting to PostgreSQL with a non-default schema.

  • Schema lost on restart: schemaName was never persisted in tabs or UserDefaults. After relaunch, the restored query omitted the schema prefix (SELECT * FROM "table" instead of SELECT * FROM "schema"."table"), causing relation does not exist errors. Now persisted through PersistedTab, QueryTab, EditorTabPayload, and AppSettingsStorage, and restored on reconnect via DatabaseManager + restoreSchemaAndRunQuery.
  • Stuck error dialog: Alert sheets used NSApp.keyWindow which could return a SwiftUI sheet window. beginSheetModal(for: sheetWindow) creates an undismissable sheet-on-sheet. Now uses a stable contentWindow reference stored on the coordinator.

Test plan

  • Connect to PostgreSQL → switch to non-public schema → open table → quit → relaunch → reconnect → verify table loads with schema-qualified query
  • Trigger a query error (e.g. invalid SQL) → verify OK button dismisses the error dialog
  • Trigger a query error while a .sheet() is open (e.g. database switcher via Cmd+D) → verify dialog still dismisses
  • Open multiple tabs across different schemas → quit → relaunch → verify all restore correctly
  • Verify backward compatibility: old persisted tab JSON (without schemaName) loads without errors
  • FK navigation on non-public schema tables works correctly
  • Preview tab mode on non-public schema tables works correctly

@datlechin datlechin force-pushed the fix/schema-persistence-and-alert-dismiss branch from 2929b60 to a4497ab Compare March 31, 2026 14:55
@datlechin datlechin merged commit 260ebdb into main Mar 31, 2026
2 checks passed
@datlechin datlechin deleted the fix/schema-persistence-and-alert-dismiss branch March 31, 2026 14:56
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.

App is unusable after reconnecting to a PostgreSQL database next time

1 participant