Skip to content

Object palette reads the database list from connection params instead of the live selection #591

Description

@verbaux

The object command palette derives its database list from the saved connection parameter, while every other consumer uses the list the provider actually resolved. The two drift apart.

src/hooks/useCommandPaletteObjectItems.ts:66-69:

const configuredDatabases = useMemo(
  () => getDatabaseList(connection?.params.database ?? ""),
  [connection?.params.database],
);

The sidebar instead reads connectionData.selectedDatabases (src/components/layout/ExplorerSidebar.tsx:140), which the provider keeps current. Neither setSelectedDatabases (src/contexts/DatabaseProvider.tsx:566) nor refreshDatabaseSelection (src/contexts/DatabaseProvider.tsx:149) writes back to params.database.

Consequences

1. All-databases mode (#572): the object palette is empty.

In that mode params.database is empty by design — the real list comes from get_available_databases at connect time (src/contexts/DatabaseProvider.tsx:676-687). So configuredDatabases resolves to [], and getNavigatorItems builds its groups exclusively from that array:

// src/utils/quickNavigator.ts:125-129
} else if (isMultiDb) {
  groups = configuredDatabases.flatMap((group) => {
    const data = databaseDataMap[group];
    return data ? [{ group, data }] : [];
  });

An empty array yields no groups and therefore no items. The eager-load effect (src/hooks/useCommandPaletteObjectItems.ts:85-89) iterates the same empty array, so nothing recovers it.

2. Stale list after a selection change.

Changing the database selection in the sidebar, the manual refresh added in #530, or the pruning of dropped databases added in #524 all update selectedDatabases only — the palette keeps offering the old set.

3. Divergent branch condition.

The palette uses isMultiDatabaseCapable(capabilities) (capability only), while the sidebar uses usesMultiDatabaseLayout(capabilities, selectedDatabases) — capability and a non-empty selection (src/utils/database.ts:50-55). The two can take different layout branches for the same connection.

Suggested fix

Read connectionData.selectedDatabases instead of getDatabaseList(connection.params.database), and align the multi-database check with usesMultiDatabaseLayout.

Notes

Pre-existing, not introduced by #545 — filed separately as agreed in that PR's review rather than growing its diff.

Found by reading the code; reproducing it needs a MySQL/MariaDB connection with an empty database field, since schema-based drivers take a different branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions