fix(plugins): stop hiding the postgres database from the database list - #1969
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Fixes #1967.
Problem
The
postgresdatabase never appeared in any database list: sidebar tree, Cmd+K quick switcher, the database switcher popover, the database filter popover, the per-tab container picker, and the Backup and Restore Dump sheets.Root cause
postgreswas classified as a system database, and system databases are filtered out unconditionally with no toggle:PostgreSQLPlugin.systemDatabaseNames = ["postgres", "template0", "template1"]DatabaseTreeVisibility.visibledrops anything flagged system.The classification is wrong. PostgreSQL's docs are explicit:
postgresis "a default database meant for use by users, utilities and third party applications", "simply a copy oftemplate1and can be dropped and recreated if necessary". Onlytemplate0andtemplate1are the standard system databases, and both carrydatistemplate = true, whichfetchDatabases()already excludes withWHERE datistemplate = false.So the list had exactly one effective entry:
postgres. Its entire net effect was hiding the one database it should never hide. Supabase, Neon, and the default Docker image all put user data there.The same mistake sat in the sibling drivers in that plugin: CockroachDB marked
postgresanddefaultdb(ordinary convenience databases) as system, Redshift markeddev(created with every cluster) as system.Secondary defect
isSystemDatabasewas computed from three hardcoded literal lists that disagreed. Redshift proved the drift was live: the registry default said["postgres", "template0", "template1"]whileRedshiftPluginDriver.fetchAllDatabaseMetadatasaid["dev", "padb_harvest"], so opening Cmd+K on Redshift hidpostgresfor a moment, then swapped to hidingdev.What changed
Classification. New
PostgreSQLSystemDatabasesholds one set per engine and replaces all six literals: PostgreSQL and PGlite[], CockroachDB["system"], Redshift["padb_harvest"]. The registry's curated defaults now match.A database you are connected to is never hidden.
DatabaseTreeVisibility.visibletakes anactiveDatabaseand keeps it in the list even when it is a system database or the filter excludes it.MainEditorContentViewalready hand-rolled this for the per-tab picker only; that copy is gone and the five call sites share one rule. This also covers MSSQL, where a blank Database field lands you onmasterand the sidebar then omitted it.Consequence worth knowing
Drop Database…in the switcher context menu is hidden for system databases, sopostgresis now droppable (still blocked while you are connected to it). That matches psql and pgAdmin, and PostgreSQL's own docs say it can be dropped and recreated.Tests
PostgreSQLSystemDatabasesTests:postgres,dev,defaultdbare not system;systemandpadb_harvestare.PluginMetadataRegistrySystemDatabaseTests: the registry's curated defaults match the plugin's sets, so the two sources cannot drift again, plus a check that no PostgreSQL-family engine hides its default landing database.DatabaseTreeVisibilityTests: the active database survives both the system filter and a non-matching selection, keeps its position, and an empty name is treated as absent.18 tests pass.
swiftlint lint --strictis clean. No PluginKit change, so no ABI bump; PostgreSQL is a bundled plugin, so nothing to publish to the registry.