feat(connections): browse available databases when creating/editing a connection#30
Merged
Conversation
… connection When a user mistypes the database name, the server connection actually succeeds (auth is fine) and PG only rejects the unknown DB — but the form gave no way to discover which databases the credentials can reach (#24). Add a list_databases command (+ _for_edit variant that fills the password from the keychain) that reuses the one-shot connect path but targets a maintenance DB (postgres, falling back to template1), so it works even when the typed database is wrong. It runs SELECT datname FROM pg_database WHERE datistemplate=false AND has_database_privilege(datname,'CONNECT') ORDER BY datname. The connection form gets a Browse databases button that feeds the results into a <datalist> for type-ahead, keeping the field free-text so a not-yet-created DB name can still be entered. Fixes #24 Signed-off-by: exzvor <exzvor@gmail.com>
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
When a user mistypes the database name, the connection to the server succeeds (host/port/auth are fine) and PG only rejects the unknown database — but the form gave no way to see which databases the credentials can actually reach (#24).
Adds a
list_databasescommand (+ a_for_editvariant that fills the password from the keychain, mirroringtest_connection_for_edit) that reuses the existing one-shot connect path but targets a maintenance DB (postgres, falling back totemplate1), so it works even when the typed database is wrong — which is the whole point. Query:The connection form gets a Browse databases button that feeds the result into a
<datalist>for type-ahead, keeping the field free-text so a not-yet-created DB name can still be typed.Related issue
Fixes #24
Tests
list_databasessucceeds with a deliberately wrong typed database (proving it uses the maintenance DB), returnspostgres, excludestemplate0/1, and is ordered. Runs for real on CI (ubuntu has Docker); skips gracefully without Docker. Verified passing locally against a real container.ConnectionForm.test.tsx: clicking Browse databases callslistDatabasesand populates the<datalist>options (25 tests pass).Self-verification
npm run typecheck/npm run lintcleannpm run testgreen (ConnectionForm 25)cargo fmt --all -- --checkclean;cargo clippy --libno findings;cargo build --bin ide99clean; integration test greenNotes for reviewer
The list is an aid, not a constraint — the Database field stays free-text (you can still type a DB you're about to create).
probe_databases/fetch_databasesmirrorrun_probe/fetch_version; minor duplication of the TLS branch was preferred over refactoring the existing probe path to keep the blast radius small.