fix(sql): preserve file associations and list selection

This commit is contained in:
zipg authored and GitHub committed 2026-08-13 11:44:55 +08:00
1 parent 2e27f7a66a
commit e5a3917f7d
25 files changed
+558 -186

No files matched your search

@@ -5,6 +5,7 @@ const savedTarget = {
connectionId: "saved-connection",
database: "saved_database",
schema: "saved_schema",
catalog: "saved_catalog",
};
describe("saved SQL execution targets", () => {
@@ -46,11 +47,13 @@ describe("saved SQL execution targets", () => {
connectionId: "runtime-connection",
database: "runtime_database",
schema: "runtime_schema",
catalog: "runtime_catalog",
}),
).toEqual({
connectionId: "runtime-connection",
database: "runtime_database",
schema: "runtime_schema",
catalog: "runtime_catalog",
});
});
});
@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";
import { savedSqlImportTarget } from "@/lib/savedSql/savedSqlImportTarget";
describe("savedSqlImportTarget", () => {
it("inherits an explicitly associated local file target at the library root", () => {
expect(savedSqlImportTarget({ connectionId: "conn-1", database: "sales", catalog: "hive" })).toEqual({
connectionId: "conn-1",
database: "sales",
catalog: "hive",
});
});
it("keeps an unassociated local file unassociated at the library root", () => {
expect(savedSqlImportTarget({ connectionId: "", database: "" })).toEqual({ connectionId: "", database: "" });
});
it("keeps the destination folder connection and inherits a matching database", () => {
expect(savedSqlImportTarget({ connectionId: "conn-1", database: "sales", catalog: "iceberg" }, { connectionId: "conn-1" })).toEqual({
connectionId: "conn-1",
database: "sales",
catalog: "iceberg",
});
});
it("does not apply a database from a different connection to the destination folder", () => {
expect(savedSqlImportTarget({ connectionId: "conn-2", database: "analytics" }, { connectionId: "conn-1" })).toEqual({
connectionId: "conn-1",
database: "",
catalog: undefined,
});
});
it("uses the destination folder for an unassociated source", () => {
expect(savedSqlImportTarget({ connectionId: "", database: "" }, { connectionId: "conn-1" })).toEqual({
connectionId: "conn-1",
database: "",
catalog: undefined,
});
});
});