Skip to content

[Bug]: Database selector shows system/maintenance databases (e.g. postgres) alongside user databases #277

Description

@marwan562

Before Submitting

  • I searched existing issues and discussions to avoid creating a duplicate.
  • I can reproduce this on the latest version of db-studio.

db-studio Version

1.13.0

Product Surface

Web App

Database Type

PostgreSQL

Other Database Type

No response

What happened?

With a single-database connection string in .env:

DATABASE_URL=postgresql://marwanhassan@localhost:5432/db_studio_test

the database selector in the bottom-left sidebar lists 2 databases: db_studio_test and postgres — even though only db_studio_test was ever created/connected. The footer also reports Databases: 2.

postgres is PostgreSQL's auto-created maintenance database (initdb creates it on every cluster). It is real, but showing it next to the application database is confusing — it looks like a second running database the user does not recognize.

Root cause: GET /databasesPgAdapter.getDatabasesList() (packages/server/src/adapters/pg/pg.adapter.ts) enumerates the whole server:

SELECT d.datname AS name, ...
FROM pg_catalog.pg_database d
WHERE d.datistemplate = false
ORDER BY d.datname;

postgres has datistemplate = false just like any user DB, so it is always returned. Same class of issue in the other adapters (only MSSQL filtered system DBs): MySQL leaks information_schema/mysql/performance_schema/sys, MongoDB leaks admin/config/local, SQLite lists internal temp.

Steps to Reproduce

  1. Set DATABASE_URL=postgresql://<user>@localhost:5432/db_studio_test in .env
  2. Run bun run dev and open the web app
  3. Look at the bottom-left Database selector → shows db_studio_test and postgres; footer shows Databases: 2
  4. Confirm server-side: SELECT datname FROM pg_database WHERE datistemplate = false; returns both rows

Expected Behavior

The selector lists only user-created databases (db_studio_test, count 1). System/maintenance databases stay hidden unless the connection string points at one of them (e.g. DATABASE_URL=.../postgres should still list postgres).

I have this fix implemented and verified locally across all five adapters (filter system DBs, always keep the currently-connected DB visible) and can open a PR if the maintainers agree with the approach.

Screenshots

Screenshot 1 — web app showing two databases (the bug)

The bottom-left Database selector lists two databases even though only one is configured:

  • db_studio_test (selected)
  • postgres ← unexpected maintenance database

The footer also reports Databases: 2.

Sidebar showing db_studio_test and postgres

Screenshot 2 — .env with a single database (expected setup)

Only one database is connected to db-studio:

DATABASE_URL=postgresql://marwanhassan@localhost:5432/db_studio_test
.env with single DATABASE_URL

Logs / Error Output

No errors — the endpoint behaves as coded; this is a UX/correctness issue, not a crash.


     datname
------------------
 db_studio_test
 postgres

Environment

OS: macOS
Browser: Chrome
Bun version: 1.4.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions