fix(oracle): export portable table DDL
This commit is contained in:
13 files changed
+241
-30
No files matched your search
@@ -1806,7 +1806,7 @@ async function confirmBatchEmptyTables() {
|
||||
async function exportStructure(row: ObjectBrowserRow) {
|
||||
try {
|
||||
const schema = row.schema || selectedSchema.value || props.database;
|
||||
const ddl = await api.getTableDdl(props.connection.id, props.database, schema, row.name, tableDdlObjectType(row.type), props.catalog);
|
||||
const ddl = await api.getTableDdl(props.connection.id, props.database, schema, row.name, tableDdlObjectType(row.type), props.catalog, true);
|
||||
await saveFileContent(buildSingleDdlExportFileContent(ddl), `${row.name}.sql`, "SQL", "sql");
|
||||
} catch (e: any) {
|
||||
console.error("Export structure failed:", e);
|
||||
|
||||
@@ -80,8 +80,8 @@ describe("useSidebarTreeExportRuntime", () => {
|
||||
|
||||
expect(connectionStore.ensureConnected).toHaveBeenNthCalledWith(1, first.connectionId);
|
||||
expect(connectionStore.ensureConnected).toHaveBeenNthCalledWith(2, second.connectionId);
|
||||
expect(apiMock.getTableDdl).toHaveBeenNthCalledWith(1, first.connectionId, first.database, first.schema, first.label, undefined, undefined);
|
||||
expect(apiMock.getTableDdl).toHaveBeenNthCalledWith(2, second.connectionId, second.database, second.schema, second.label, "VIEW", undefined);
|
||||
expect(apiMock.getTableDdl).toHaveBeenNthCalledWith(1, first.connectionId, first.database, first.schema, first.label, undefined, undefined, true);
|
||||
expect(apiMock.getTableDdl).toHaveBeenNthCalledWith(2, second.connectionId, second.database, second.schema, second.label, "VIEW", undefined, true);
|
||||
expect(structurePreviewSql.value).toBe("CREATE TABLE one (id INT);\n\nCREATE VIEW two AS SELECT 1;\n");
|
||||
expect(structurePreviewTitle.value).toBe("contextMenu.exportStructurePreviewTitleMultiple");
|
||||
expect(showStructurePreviewDialog.value).toBe(true);
|
||||
|
||||
@@ -75,7 +75,7 @@ export function useSidebarTreeExportRuntime(options: SidebarTreeExportRuntimeOpt
|
||||
const parts: string[] = [];
|
||||
for (const target of targets) {
|
||||
await connectionStore.ensureConnected(target.connectionId);
|
||||
const ddl = await api.getTableDdl(target.connectionId, target.database, target.schema || target.database, target.label, tableDdlObjectTypeForNode(target.type), target.catalog);
|
||||
const ddl = await api.getTableDdl(target.connectionId, target.database, target.schema || target.database, target.label, tableDdlObjectTypeForNode(target.type), target.catalog, true);
|
||||
parts.push(ddl.trim());
|
||||
}
|
||||
structurePreviewSql.value = joinExportedDdls(parts);
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ describe("ObjectBrowser DDL API boundaries", () => {
|
||||
});
|
||||
|
||||
it("keeps structure exports on the portable base DDL", () => {
|
||||
expect(exportStructureSource).toMatch(/api\.getTableDdl\([\s\S]*?props\.catalog\);/);
|
||||
expect(exportStructureSource).toMatch(/api\.getTableDdl\([\s\S]*?props\.catalog, true\);/);
|
||||
expect(exportStructureSource).not.toContain("api.getTableDisplayDdl(");
|
||||
});
|
||||
});
|
||||
@@ -873,8 +873,8 @@ export async function listSubpartitions(connectionId: string, database: string,
|
||||
return get(`/api/schema/subpartitions?${qs({ connection_id: connectionId, database, schema, table, catalog })}`);
|
||||
}
|
||||
|
||||
export async function getTableDdl(connectionId: string, database: string, schema: string, table: string, objectType?: ObjectSourceKind, catalog?: string): Promise<string> {
|
||||
return get(`/api/schema/ddl?${qs({ connection_id: connectionId, database, schema, table, object_type: objectType, catalog })}`);
|
||||
export async function getTableDdl(connectionId: string, database: string, schema: string, table: string, objectType?: ObjectSourceKind, catalog?: string, portable = false): Promise<string> {
|
||||
return get(`/api/schema/ddl?${qs({ connection_id: connectionId, database, schema, table, object_type: objectType, catalog, portable })}`);
|
||||
}
|
||||
|
||||
export async function getTableDisplayDdl(connectionId: string, database: string, schema: string, table: string, objectType?: ObjectSourceKind, catalog?: string): Promise<string> {
|
||||
|
||||
@@ -1654,7 +1654,7 @@ export async function listSubpartitions(connectionId: string, database: string,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTableDdl(connectionId: string, database: string, schema: string, table: string, objectType?: ObjectSourceKind, catalog?: string): Promise<string> {
|
||||
export async function getTableDdl(connectionId: string, database: string, schema: string, table: string, objectType?: ObjectSourceKind, catalog?: string, portable = false): Promise<string> {
|
||||
return invoke("get_table_ddl", {
|
||||
connectionId,
|
||||
database,
|
||||
@@ -1662,6 +1662,7 @@ export async function getTableDdl(connectionId: string, database: string, schema
|
||||
table,
|
||||
objectType,
|
||||
catalog,
|
||||
portable,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1674,6 +1675,7 @@ export async function getTableDisplayDdl(connectionId: string, database: string,
|
||||
objectType,
|
||||
catalog,
|
||||
includePostgresAccess: true,
|
||||
portable: false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user