fix(sql): preserve file associations and list selection
This commit is contained in:
25 files changed
+558
-186
No files matched your search
@@ -9,7 +9,7 @@ export interface SavedSqlExecutionTarget {
|
||||
catalog?: string;
|
||||
}
|
||||
|
||||
type SavedSqlFileTarget = Pick<SavedSqlFile, "connectionId" | "database" | "schema">;
|
||||
type SavedSqlFileTarget = Pick<SavedSqlFile, "connectionId" | "database" | "schema" | "catalog">;
|
||||
type QueryTabTarget = Pick<QueryTab, "connectionId" | "database" | "schema" | "catalog">;
|
||||
|
||||
export function savedSqlExecutionTargetFromFile(file: SavedSqlFileTarget): SavedSqlExecutionTarget {
|
||||
@@ -17,6 +17,7 @@ export function savedSqlExecutionTargetFromFile(file: SavedSqlFileTarget): Saved
|
||||
connectionId: file.connectionId,
|
||||
database: file.database,
|
||||
schema: file.schema,
|
||||
catalog: file.catalog,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,5 +41,6 @@ export function savedSqlDefaultTargetForWrite(currentTarget: SavedSqlExecutionTa
|
||||
connectionId: currentTarget.connectionId,
|
||||
database: currentTarget.database,
|
||||
schema: currentTarget.schema,
|
||||
catalog: currentTarget.catalog,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { SavedSqlFolder } from "@/types/database";
|
||||
import type { ExternalSqlFileTarget } from "@/lib/sql/externalSqlFileTarget";
|
||||
|
||||
export function savedSqlImportTarget(sourceTarget: ExternalSqlFileTarget, folder?: Pick<SavedSqlFolder, "connectionId">): ExternalSqlFileTarget {
|
||||
if (!folder) return sourceTarget;
|
||||
return {
|
||||
connectionId: folder.connectionId,
|
||||
database: sourceTarget.connectionId === folder.connectionId ? sourceTarget.database : "",
|
||||
catalog: sourceTarget.connectionId === folder.connectionId ? sourceTarget.catalog : undefined,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user