Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(schema-diff): pass objectType for views so Dameng GET_DDL uses VIEW not TABLE

t8y2d3f7ba2cc955
diff --git a/apps/desktop/src/components/diff/SchemaDiffDialog.vue b/apps/desktop/src/components/diff/SchemaDiffDialog.vue
index 600388c13b..a689465d3c 100644
--- a/apps/desktop/src/components/diff/SchemaDiffDialog.vue
+++ b/apps/desktop/src/components/diff/SchemaDiffDialog.vue
@@ -263,6 +263,20 @@ function handleOptionsUpdate(options: SchemaDiffCompareOptions) {
}
}
+/** Map a JDBC table_type to an ObjectSourceKind for getTableDdl routing.
+ * Views and materialized views need the object_type parameter so the
+ * backend can call DBMS_METADATA.GET_DDL with the correct type. */
+function isViewOrMaterializedView(tableType: string): ObjectSourceKind | undefined {
+ switch (tableType.toUpperCase()) {
+ case "VIEW":
+ return "VIEW";
+ case "MATERIALIZED VIEW":
+ return "MATERIALIZED_VIEW";
+ default:
+ return undefined;
+ }
+}
+
async function handleCompare() {
loading.value = true;
step.value = "compare";
@@ -276,12 +290,13 @@ async function handleCompare() {
// Load schema details in parallel
const sourceDetails = await Promise.all(
srcTables.map(async (table) => {
+ const objectType = isViewOrMaterializedView(table.table_type);
const [columns, indexes, foreignKeys, triggers, ddl] = await Promise.all([
api.getColumns(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name),
api.listIndexes(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name),
api.listForeignKeys(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name),
api.listTriggers(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name),
- api.getTableDdl(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name),
+ api.getTableDdl(sourceConnectionId.value, sourceDatabase.value, sourceSchema.value, table.name, objectType),
]);
return { name: table.name, columns, indexes, foreignKeys, triggers, ddl };
}),
@@ -289,12 +304,13 @@ async function handleCompare() {
const targetDetails = await Promise.all(
tgtTables.map(async (table) => {
+ const objectType = isViewOrMaterializedView(table.table_type);
const [columns, indexes, foreignKeys, triggers, ddl] = await Promise.all([
api.getColumns(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name),
api.listIndexes(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name),
api.listForeignKeys(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name),
api.listTriggers(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name),
- api.getTableDdl(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name),
+ api.getTableDdl(targetConnectionId.value, targetDatabase.value, targetSchema.value, table.name, objectType),
]);
return { name: table.name, columns, indexes, foreignKeys, triggers, ddl };
}),