fix(quick-open): search unloaded tables after cold start
This commit is contained in:
6 files changed
+211
-29
No files matched your search
@@ -32,4 +32,9 @@ describe("defaultDatabase selectable values", () => {
|
||||
expect(isDefaultDatabase({ db_type: "sqlite", database: "analytics" }, "analytics")).toBe(true);
|
||||
expect(resolveDefaultDatabase({ db_type: "sqlite", host: "primary.db", database: undefined }, ["analytics.db"])).toBe("analytics.db");
|
||||
});
|
||||
|
||||
it("matches PostgreSQL backend defaults when the configured database is empty", () => {
|
||||
expect(resolveDefaultDatabase({ db_type: "postgres", database: "" }, [])).toBe("postgres");
|
||||
expect(resolveDefaultDatabase({ db_type: "postgres", driver_profile: "cockroachdb", database: " " }, [])).toBe("defaultdb");
|
||||
});
|
||||
});
|
||||
@@ -5,10 +5,12 @@ import { normalizeSqliteNamespace } from "@/lib/database/sqliteNamespace";
|
||||
export const TREE_SCHEMA_DEFAULT_DATABASE_SELECT_VALUE = "__dbx_tree_schema_default_database__";
|
||||
export const EMPTY_DATABASE_SELECT_VALUE = "__dbx_empty_database__";
|
||||
|
||||
export function resolveDefaultDatabase(connection: Pick<ConnectionConfig, "database"> & Partial<Pick<ConnectionConfig, "db_type" | "host">>, options: string[]): string {
|
||||
export function resolveDefaultDatabase(connection: Pick<ConnectionConfig, "database"> & Partial<Pick<ConnectionConfig, "db_type" | "driver_profile" | "host">>, options: string[]): string {
|
||||
if (connection.db_type === "cloudflare-d1") return "main";
|
||||
if (connection.db_type === "sqlite") return normalizeSqliteNamespace(connection.database || options[0], connection);
|
||||
return connection.database || options[0] || "";
|
||||
if (connection.database?.trim()) return connection.database;
|
||||
if (connection.db_type === "postgres") return connection.driver_profile === "cockroachdb" ? "defaultdb" : "postgres";
|
||||
return options[0] || "";
|
||||
}
|
||||
|
||||
export function isTreeSchemaDefaultDatabase(dbType: DatabaseType | undefined, database: string): boolean {
|
||||
|
||||
Reference in new issue
Block a user