fix(sql): restore SQL file schema for sidebar locate

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-09-01 16:21:40 +08:00
1 parent 440c41f5b9
commit e9a90173a6
11 files changed
+175 -53

No files matched your search

@@ -26,6 +26,26 @@ describe("external SQL file targets", () => {
expect(resolveExternalSqlFileTarget("/work/iceberg.sql", () => true, unassociatedExternalSqlFileTarget()).catalog).toBe("iceberg");
});
it("restores the schema the file was saved from", () => {
// Reopening a .sql file used to drop the schema, leaving the tab on the
// connection default: sidebar locate then looked for the table in the wrong
// namespace and silently did nothing (issue #7648).
rememberExternalSqlFileTarget("/work/report.sql", { connectionId: "saved-connection", database: "dbx_test", schema: "analytics" });
expect(resolveExternalSqlFileTarget("/work/report.sql", () => true, unassociatedExternalSqlFileTarget())).toEqual({
connectionId: "saved-connection",
database: "dbx_test",
catalog: undefined,
schema: "analytics",
});
});
it("treats historical records without a schema as unset", () => {
localStorage.setItem(EXTERNAL_SQL_FILE_TARGETS_STORAGE_KEY, JSON.stringify([{ path: "/work/legacy.sql", connectionId: "saved-connection", database: "sales", updatedAt: 1 }]));
expect(resolveExternalSqlFileTarget("/work/legacy.sql", () => true, unassociatedExternalSqlFileTarget()).schema).toBeUndefined();
});
it("treats historical records without catalog as the default catalog", () => {
localStorage.setItem(EXTERNAL_SQL_FILE_TARGETS_STORAGE_KEY, JSON.stringify([{ path: "/work/legacy.sql", connectionId: "saved-connection", database: "sales", updatedAt: 1 }]));