Skip to content

feat(connections): browse available databases when creating/editing a connection#30

Merged
exzvor merged 2 commits into
mainfrom
feat/24-list-databases
Jun 2, 2026
Merged

feat(connections): browse available databases when creating/editing a connection#30
exzvor merged 2 commits into
mainfrom
feat/24-list-databases

Conversation

@exzvor

@exzvor exzvor commented Jun 2, 2026

Copy link
Copy Markdown
Owner

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_databases command (+ a _for_edit variant that fills the password from the keychain, mirroring test_connection_for_edit) that reuses the existing one-shot connect path but targets a maintenance DB (postgres, falling back to template1), so it works even when the typed database is wrong — which is the whole point. Query:

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 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

  • Backend integration test (testcontainers Postgres 17) — list_databases succeeds with a deliberately wrong typed database (proving it uses the maintenance DB), returns postgres, excludes template0/1, and is ordered. Runs for real on CI (ubuntu has Docker); skips gracefully without Docker. Verified passing locally against a real container.
  • Frontend test — ConnectionForm.test.tsx: clicking Browse databases calls listDatabases and populates the <datalist> options (25 tests pass).
  • Manual smoke — recommended: enter host/user (any database), click Browse → the field offers the real DB list.

Self-verification

  • npm run typecheck / npm run lint clean
  • npm run test green (ConnectionForm 25)
  • cargo fmt --all -- --check clean; cargo clippy --lib no findings; cargo build --bin ide99 clean; integration test green
  • DCO sign-off

Notes 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_databases mirror run_probe/fetch_version; minor duplication of the TLS branch was preferred over refactoring the existing probe path to keep the blast radius small.

exzvor added 2 commits June 2, 2026 13:12
… 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>
@exzvor exzvor merged commit 9b8f40a into main Jun 2, 2026
2 checks passed
@exzvor exzvor deleted the feat/24-list-databases branch June 2, 2026 10:22
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.

[feature] автодополнение списка доступных пользователю БД при создании соединения

1 participant