fix(sqlite): normalize database context routing
This commit is contained in:
1 parent
545c2c9e00
commit
d0a55b1b07
23 files changed
+499
-69
No files matched your search
+32
-2
@@ -28,7 +28,7 @@ describe("resolveNewQueryTarget", () => {
|
||||
database: "bi",
|
||||
objectBrowser: { catalog: "paimon_catalog" },
|
||||
},
|
||||
connections: [{ id: "conn-1", database: "" }],
|
||||
connections: [{ id: "conn-1", host: "localhost", database: "", db_type: "starrocks" }],
|
||||
preferredSource: "tab",
|
||||
}),
|
||||
).toEqual({
|
||||
@@ -53,10 +53,40 @@ describe("resolveNewQueryTarget", () => {
|
||||
primaryKeys: [],
|
||||
},
|
||||
},
|
||||
connections: [{ id: "conn-1", database: "" }],
|
||||
connections: [{ id: "conn-1", host: "localhost", database: "", db_type: "starrocks" }],
|
||||
})?.catalog,
|
||||
).toBe("paimon_catalog");
|
||||
});
|
||||
|
||||
it("repairs a stale SQLite file path inherited from an active tab", () => {
|
||||
expect(
|
||||
resolveNewQueryTarget({
|
||||
activeTab: {
|
||||
connectionId: "conn-sqlite",
|
||||
database: "/tmp/stale.sqlite",
|
||||
},
|
||||
connections: [{ id: "conn-sqlite", host: "/tmp/stale.sqlite", database: "/tmp/stale.sqlite", db_type: "sqlite" }],
|
||||
}),
|
||||
).toEqual({
|
||||
connectionId: "conn-sqlite",
|
||||
database: "main",
|
||||
schema: undefined,
|
||||
catalog: undefined,
|
||||
shouldRefreshDefaultDatabase: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves an attached SQLite database alias inherited from an active tab", () => {
|
||||
expect(
|
||||
resolveNewQueryTarget({
|
||||
activeTab: {
|
||||
connectionId: "conn-sqlite",
|
||||
database: "analytics.db",
|
||||
},
|
||||
connections: [{ id: "conn-sqlite", host: "primary.db", database: undefined, db_type: "sqlite" }],
|
||||
})?.database,
|
||||
).toBe("analytics.db");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveNewQueryTable", () => {
|
||||
|
||||
Reference in new issue
Block a user