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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(postgres): use COMMENT ON FOREIGN TABLE for foreign tables
YingNing7be6bb59aa74
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.tsindex f091adb10f..64e69966ca 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts+++ b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts@@ -437,7 +437,7 @@ beforeEach(() => {// TableStructureEditor probes the partition status for PostgreSQL tables// (PR #6361); a resolved non-partitioned result keeps metadata loads on the// original facet expectations unchanged.- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });});afterEach(() => {diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vueindex 62c31ec604..9437f3df91 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.vue+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue@@ -520,6 +520,10 @@ const indexes = ref<EditableStructureIndex[]>([]);const isPartitionedParent = ref(false);// True when the edited table is itself a member partition of another table.const isTablePartition = ref(false);+// True when the edited table is a PostgreSQL foreign table (relkind = 'f').+// PostgreSQL requires `COMMENT ON FOREIGN TABLE` for these, so the SQL+// preview must know which form to generate.+const isForeignTable = ref(false);// The partition-status probe has settled (success or failure), so the tab can// be hidden without hiding it merely because the probe is still in flight.const partitionStatusResolved = ref(false);@@ -535,6 +539,7 @@ async function probePartitionsTabVisibility() {if (!tableMetadataCapabilities.value.partitions || isCreateMode.value) {isPartitionedParent.value = false;isTablePartition.value = false;+ isForeignTable.value = false;partitionStatusResolved.value = true;return;}@@ -551,11 +556,13 @@ async function probePartitionsTabVisibility() {if (requestId !== partitionTabProbeRequestId) return;isPartitionedParent.value = status.isPartitionedParent;isTablePartition.value = status.isPartition;+ isForeignTable.value = status.isForeign;partitionStatusResolved.value = true;} catch {if (requestId !== partitionTabProbeRequestId) return;isPartitionedParent.value = false;isTablePartition.value = false;+ isForeignTable.value = false;// A failed probe leaves the concurrent-index availability unknown, so keep// the documented fail-closed behavior (disable Concurrent) instead of// assuming the table is a plain, non-partitioned one.@@ -2524,6 +2531,7 @@ function structureChangeOptions(): BuildTableStructureChangeSqlOptions {transwarpCreate: isCreateMode.value && databaseType.value === "transwarp" ? buildInceptorCreateOptions(physicalOptions.value, columns.value) : undefined,tableCollation: mysqlTableDefaultCollation.value || undefined,partitioned: isPartitionedParent.value,+ foreignTable: isForeignTable.value,isGaussdbMMode: connection.value?.driver_profile?.toLowerCase() === "gaussdb-m",};}@@ -2691,6 +2699,7 @@ function resetState() {secondaryMetadataErrors.value = {};isPartitionedParent.value = false;isTablePartition.value = false;+ isForeignTable.value = false;partitionStatusResolved.value = false;partitionStatusKnown.value = true;concurrentAvailabilityInvalidated.value = false;@@ -3005,8 +3014,8 @@ async function loadStructure(// status we cannot rule out a partitioned parent, so Concurrent is// treated as unavailable until a later reload re-runs the probe..then((status) => ({ known: true, status }))- .catch(() => ({ known: false, status: { isPartitionedParent: false, isPartition: false } }))- : Promise.resolve({ known: true, status: { isPartitionedParent: false, isPartition: false } });+ .catch(() => ({ known: false, status: { isPartitionedParent: false, isPartition: false, isForeign: false } }))+ : Promise.resolve({ known: true, status: { isPartitionedParent: false, isPartition: false, isForeign: false } });const columnsLoad = effectiveScope.columns ? loadObjectMetadataFacet(metadataRequest, "columns", () => api.getColumns(connectionId, database, schema, tableName, catalog), { force: forceMetadata }) : undefined;const columnsPromise = columnsLoad? columnsLoad.then((result) => {@@ -3085,6 +3094,7 @@ async function loadStructure(partitionStatusKnown.value = partitionStatus.known;isPartitionedParent.value = partitionStatus.status.isPartitionedParent;isTablePartition.value = partitionStatus.status.isPartition;+ isForeignTable.value = partitionStatus.status.isForeign;partitionStatusResolved.value = true;// Availability inputs changed: fail closed while the status is unknown,// but preserve the user's Concurrent intent so a later successful probediff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.concurrentTransition.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.concurrentTransition.spec.tsindex f64531b49c..cfc1d712de 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.concurrentTransition.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.concurrentTransition.spec.ts@@ -263,7 +263,7 @@ async function mountIndexesEditor() {mocks.ensureConnected.mockResolvedValue(undefined);mocks.executeQuery.mockResolvedValue({ columns: ["user", "host", "plugin"], rows: [["app_user", "LOGIN", ""]] });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.loadObjectDdl.mockResolvedValue({ ddl: "CREATE TABLE users (id bigint)", cacheStatus: "remote" });mocks.loadObjectMetadataFacet.mockImplementation(async (_request, facet: string) => ({value: facet === "comment" ? "" : facet === "owner" ? "app_user" : [],@@ -311,7 +311,7 @@ function concurrentCheckboxInRow(row: HTMLElement): HTMLInputElement {beforeEach(() => {vi.clearAllMocks();- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("app_user");mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });});@@ -376,7 +376,7 @@ describe("TableStructureEditor concurrent availability transition", () => {// Recovery: a later successful probe must lift the blocker and regenerate// the preview with the original Concurrent intent, never a blocking CREATE.- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });buttonWithText(root, "structureEditor.refresh").click();await vi.waitFor(() => expect(mocks.getTablePartitionStatus).toHaveBeenCalledTimes(3), { timeout: 3000 });await vi.waitFor(() => expect(mocks.buildTableStructureChangeSql.mock.calls.length).toBeGreaterThan(callsAtEnabledPhase), { timeout: 3000 });diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.createModeSavedName.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.createModeSavedName.spec.tsindex d8122a2ac0..ca146a4f25 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.createModeSavedName.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.createModeSavedName.spec.ts@@ -331,7 +331,7 @@ beforeEach(() => {mocks.executeQuery.mockResolvedValue({ columns: [], rows: [] });mocks.executeBatch.mockResolvedValue({ rowsAffected: 0 });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("");mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildTableStructureChangeSql.mockResolvedValue({ statements: [], warnings: [] });diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTab.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTab.spec.tsindex 92a93d24fc..89ac9c36d2 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTab.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTab.spec.ts@@ -392,7 +392,7 @@ beforeEach(() => {mocks.executeQuery.mockResolvedValue({ columns: [], rows: [] });mocks.executeBatch.mockResolvedValue({ rowsAffected: 0 });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("");mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildTableStructureChangeSql.mockResolvedValue({ statements: [], warnings: [] });diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.tsindex 12f9aaca26..78ab2cc2b8 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.ddlTabLifecycle.spec.ts@@ -241,7 +241,7 @@ beforeEach(() => {mocks.listDataTypes.mockResolvedValue([]);mocks.buildTableStructureChangeSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("app_user");mocks.loadObjectDdl.mockResolvedValue({ ddl: DDL, cacheStatus: "remote" });mocks.loadObjectMetadataFacet.mockImplementation(async (_request, facet: string) => ({diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.tsindex 21a5929f15..125e034185 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.initialTab.spec.ts@@ -347,7 +347,7 @@ beforeEach(() => {mocks.executeQuery.mockResolvedValue({ columns: [], rows: [] });mocks.executeBatch.mockResolvedValue({ rowsAffected: 0 });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("");mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildTableStructureChangeSql.mockResolvedValue({ statements: [], warnings: [] });diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.tsindex 2c48b88c49..dae618a564 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.metadataRevalidation.spec.ts@@ -323,7 +323,7 @@ beforeEach(() => {mocks.executeQuery.mockResolvedValue({ columns: [], rows: [] });mocks.executeBatch.mockResolvedValue({ rowsAffected: 0 });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });mocks.getTableOwner.mockResolvedValue("");mocks.buildTableOwnerChangeSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildTableStructureChangeSql.mockResolvedValue({ statements: [], warnings: [] });diff --git a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.partitionsTab.spec.ts b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.partitionsTab.spec.tsindex 295f9d7bdd..34901fc86b 100644--- a/apps/desktop/src/components/structure/__tests__/TableStructureEditor.partitionsTab.spec.ts+++ b/apps/desktop/src/components/structure/__tests__/TableStructureEditor.partitionsTab.spec.ts@@ -378,7 +378,7 @@ beforeEach(() => {mocks.executeQuery.mockResolvedValue({ columns: [], rows: [] });mocks.executeBatch.mockResolvedValue({ rowsAffected: 0 });mocks.listDataTypes.mockResolvedValue([]);- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: true, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: true, isPartition: false, isForeign: false });mocks.buildTablePartitionOperationSql.mockResolvedValue({ statements: [], warnings: [] });mocks.buildCreatePartitionedTableSql.mockResolvedValue({ statements: [], warnings: [] });mocks.getTablePartitioning.mockResolvedValue({@@ -510,6 +510,24 @@ describe("TableStructureEditor partitions tab", () => {expect(args.options.tableName).toBe("users");});+ it("passes the foreign-table flag into the structure SQL preview", async () => {+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: true, isPartition: false, isForeign: true });++ const root = await mountStructureEditor({+ initialTab: "partitions",+ initialTabRequestId: 1,+ draft: structureDraft({ tableComment: "港口资料", originalTableComment: "" }),+ });+ await settle();++ // The SQL preview is debounced, so wait for the builder rather than+ // assuming it ran within the microtask settle loop.+ await vi.waitFor(() => expect(mocks.buildTableStructureChangeSql).toHaveBeenCalled(), { timeout: 3000 });+ const options = mocks.buildTableStructureChangeSql.mock.calls.at(-1)?.[0] as { foreignTable?: boolean };+ expect(options.foreignTable).toBe(true);+ expect(root.textContent ?? "").not.toBe("");+ });+it("shows the Partitions tab for KingbaseES connections", async () => {// Regression: the status probe used to be gated on db_type === "postgres",// which hid the tab on every other PostgreSQL-family engine.@@ -534,7 +552,7 @@ describe("TableStructureEditor partitions tab", () => {});it("hides the Partitions tab for a table that is not partitioned", async () => {- mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false });+ mocks.getTablePartitionStatus.mockResolvedValue({ isPartitionedParent: false, isPartition: false, isForeign: false });const root = await mountStructureEditor();await settle();diff --git a/apps/desktop/src/lib/backend/http.ts b/apps/desktop/src/lib/backend/http.tsindex 21e555d5fe..bb9f5e830f 100644--- a/apps/desktop/src/lib/backend/http.ts+++ b/apps/desktop/src/lib/backend/http.ts@@ -1297,6 +1297,7 @@ export async function listPartitions(connectionId: string, database: string, schexport interface TablePartitionStatus {isPartitionedParent: boolean;isPartition: boolean;+ isForeign: boolean;}export async function getTablePartitionStatus(connectionId: string, database: string, schema: string, table: string): Promise<TablePartitionStatus> {diff --git a/apps/desktop/src/lib/backend/tauri.ts b/apps/desktop/src/lib/backend/tauri.tsindex 3dbd34eb6e..65cad63acb 100644--- a/apps/desktop/src/lib/backend/tauri.ts+++ b/apps/desktop/src/lib/backend/tauri.ts@@ -2529,6 +2529,7 @@ export async function listPartitions(connectionId: string, database: string, schexport interface TablePartitionStatus {isPartitionedParent: boolean;isPartition: boolean;+ isForeign: boolean;}export async function getTablePartitionStatus(connectionId: string, database: string, schema: string, table: string): Promise<TablePartitionStatus> {diff --git a/apps/desktop/src/lib/table/tableStructureEditorSql.ts b/apps/desktop/src/lib/table/tableStructureEditorSql.tsindex 426a7b2471..51429ea33f 100644--- a/apps/desktop/src/lib/table/tableStructureEditorSql.ts+++ b/apps/desktop/src/lib/table/tableStructureEditorSql.ts@@ -101,6 +101,10 @@ export interface BuildTableStructureChangeSqlOptions {* the backend rejects `CREATE INDEX CONCURRENTLY` on such tables (fail* closed) instead of downgrading to a blocking `CREATE INDEX`. */partitioned?: boolean;+ /** The target table is a PostgreSQL foreign table (`relkind = 'f'`);+ * PostgreSQL rejects `COMMENT ON TABLE` for these, so the backend must+ * generate `COMMENT ON FOREIGN TABLE`. */+ foreignTable?: boolean;/** When true, the connection is GaussDB M-mode which uses MySQL-compatible* SQL dialect with backtick quoting. */isGaussdbMMode?: boolean;diff --git a/crates/dbx-core/src/schema/mod.rs b/crates/dbx-core/src/schema/mod.rsindex 6cfc5d6f93..98a1593cb3 100644--- a/crates/dbx-core/src/schema/mod.rs+++ b/crates/dbx-core/src/schema/mod.rs@@ -8641,6 +8641,11 @@ pub struct TablePartitionStatus {pub is_partitioned_parent: bool,/// The table is itself a partition of a parent (`pg_class.relispartition`).pub is_partition: bool,+ /// The table is a foreign table (`pg_class.relkind = 'f'`). PostgreSQL+ /// requires `COMMENT ON FOREIGN TABLE` (not `COMMENT ON TABLE`) for these,+ /// so the structure editor needs this to generate a working statement.+ #[serde(default)]+ pub is_foreign: bool,}pub async fn table_partition_status_core(@@ -8656,7 +8661,11 @@ pub async fn table_partition_status_core(match pool_handle.as_ref() {Some(PoolKind::Postgres(pool)) => {let info = db::postgres::get_table_partition_info(pool, schema, table).await?;- Ok(TablePartitionStatus { is_partitioned_parent: info.key.is_some(), is_partition: info.is_partition })+ Ok(TablePartitionStatus {+ is_partitioned_parent: info.key.is_some(),+ is_partition: info.is_partition,+ is_foreign: info.is_foreign,+ })}Some(PoolKind::Agent(client)) => {// Resolve the config once: it gates the arm and feeds the RPCdiff --git a/crates/dbx-core/src/schema/table_structure_sql/sqlite_rebuild.rs b/crates/dbx-core/src/schema/table_structure_sql/sqlite_rebuild.rsindex 204f7cf64a..a593974da4 100644--- a/crates/dbx-core/src/schema/table_structure_sql/sqlite_rebuild.rs+++ b/crates/dbx-core/src/schema/table_structure_sql/sqlite_rebuild.rs@@ -1522,6 +1522,7 @@ mod tests {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,}diff --git a/crates/dbx-core/tests/live_mysql_column_name_whitespace.rs b/crates/dbx-core/tests/live_mysql_column_name_whitespace.rsindex 4520e46c8c..a2d1145d88 100644--- a/crates/dbx-core/tests/live_mysql_column_name_whitespace.rs+++ b/crates/dbx-core/tests/live_mysql_column_name_whitespace.rs@@ -54,6 +54,7 @@ fn change_options(table_name: &str, columns: Vec<EditableStructureColumn>) -> Tamysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,}diff --git a/crates/dbx-core/tests/live_mysql_generated_columns.rs b/crates/dbx-core/tests/live_mysql_generated_columns.rsindex c16110727a..b82b313552 100644--- a/crates/dbx-core/tests/live_mysql_generated_columns.rs+++ b/crates/dbx-core/tests/live_mysql_generated_columns.rs@@ -50,6 +50,7 @@ fn change_options(table_name: &str, columns: Vec<EditableStructureColumn>) -> Tamysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,}diff --git a/crates/dbx-core/tests/live_postgres_concurrent_index.rs b/crates/dbx-core/tests/live_postgres_concurrent_index.rsindex 2b2bb2eb74..30b007e8d7 100644--- a/crates/dbx-core/tests/live_postgres_concurrent_index.rs+++ b/crates/dbx-core/tests/live_postgres_concurrent_index.rs@@ -64,6 +64,7 @@ async fn live_postgres_concurrent_index_builds_valid_index() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -198,6 +199,7 @@ async fn live_postgres_partitioned_parent_concurrent_request_rejected() {mysql_engine: None,transwarp_create: None,partitioned: true,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});diff --git a/crates/dbx-core/tests/live_postgres_partitioning.rs b/crates/dbx-core/tests/live_postgres_partitioning.rsindex 809d6c4fbd..56c98a13b7 100644--- a/crates/dbx-core/tests/live_postgres_partitioning.rs+++ b/crates/dbx-core/tests/live_postgres_partitioning.rs@@ -316,6 +316,7 @@ async fn live_postgres_create_partitioned_table_executes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,};diff --git a/crates/dbx-core/tests/live_sqlserver_completion.rs b/crates/dbx-core/tests/live_sqlserver_completion.rsindex df1d40cefe..ace0bf2b54 100644--- a/crates/dbx-core/tests/live_sqlserver_completion.rs+++ b/crates/dbx-core/tests/live_sqlserver_completion.rs@@ -1023,6 +1023,7 @@ async fn live_sqlserver_table_structure_default_changes_drop_existing_constraintmysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});diff --git a/crates/dbx-sql-schema/src/db_admin_sql.rs b/crates/dbx-sql-schema/src/db_admin_sql.rsindex d7d47efd95..ad86fa80f5 100644--- a/crates/dbx-sql-schema/src/db_admin_sql.rs+++ b/crates/dbx-sql-schema/src/db_admin_sql.rs@@ -3102,6 +3102,7 @@ mod tests {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});diff --git a/crates/dbx-sql-schema/src/table_structure_sql/comments.rs b/crates/dbx-sql-schema/src/table_structure_sql/comments.rsindex 0cb31f3ff1..8065483bae 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/comments.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/comments.rs@@ -27,6 +27,12 @@ pub(super) fn build_table_comment_sql(options: &TableStructureSqlOptions, warninStructureDialect::Mysql | StructureDialect::GaussdbM => {vec![format!("ALTER TABLE {table} COMMENT = {quoted};")]}+ StructureDialect::Postgres if options.foreign_table => {+ // PostgreSQL foreign tables (relkind = 'f') reject+ // `COMMENT ON TABLE` ("<name>" is not a table) and require the+ // FOREIGN form instead.+ vec![format!("COMMENT ON FOREIGN TABLE {table} IS {quoted};")]+ }StructureDialect::Postgres| StructureDialect::Oracle| StructureDialect::Dameng@@ -216,6 +222,54 @@ fn is_sqlserver_legacy_profile(driver_profile: Option<&str>) -> bool {mod tests {use super::*;+ fn pg_comment_options(foreign_table: bool) -> TableStructureSqlOptions {+ TableStructureSqlOptions {+ database_type: Some(DatabaseType::Postgres),+ driver_profile: None,+ schema: Some("de_sk".to_string()),+ table_name: "vmes_base_destination".to_string(),+ columns: Vec::new(),+ indexes: Vec::new(),+ foreign_keys: Vec::new(),+ triggers: Vec::new(),+ table_comment: Some("港口资料".to_string()),+ original_table_comment: None,+ mysql_engine: None,+ transwarp_create: None,+ partitioned: false,+ is_gaussdb_m_mode: false,+ table_collation: None,+ foreign_table,+ }+ }++ #[test]+ fn postgres_foreign_table_comment_uses_foreign_table_form() {+ let mut warnings = Vec::new();+ let statements = build_table_comment_sql(&pg_comment_options(true), &mut warnings);++ assert_eq!(statements, vec!["COMMENT ON FOREIGN TABLE \"de_sk\".\"vmes_base_destination\" IS '港口资料';"]);+ assert!(warnings.is_empty(), "no warnings expected: {warnings:?}");+ }++ #[test]+ fn postgres_regular_table_comment_keeps_table_form() {+ let mut warnings = Vec::new();+ let statements = build_table_comment_sql(&pg_comment_options(false), &mut warnings);++ assert_eq!(statements, vec!["COMMENT ON TABLE \"de_sk\".\"vmes_base_destination\" IS '港口资料';"]);+ }++ #[test]+ fn foreign_table_flag_is_ignored_by_non_postgres_dialects() {+ let mut options = pg_comment_options(true);+ options.database_type = Some(DatabaseType::Oracle);+ let mut warnings = Vec::new();+ let statements = build_table_comment_sql(&options, &mut warnings);++ assert_eq!(statements, vec!["COMMENT ON TABLE \"de_sk\".\"vmes_base_destination\" IS '港口资料';"]);+ }+#[test]fn sqlserver_table_comment_updates_or_adds_without_dropping() {let statements = build_sqlserver_table_comment_sql("[app's].[user's]", Some("app's"), "user's", "owner's 新值");diff --git a/crates/dbx-sql-schema/src/table_structure_sql/tests.rs b/crates/dbx-sql-schema/src/table_structure_sql/tests.rsindex 994d2252c5..8c3776fe26 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/tests.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/tests.rs@@ -64,6 +64,7 @@ fn structure_change_options(mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,}@@ -353,6 +354,7 @@ fn index_change_options(mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,}@@ -436,6 +438,7 @@ fn builds_mysql_column_and_index_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -799,6 +802,7 @@ fn builds_xugu_type_change_with_native_syntax() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1066,6 +1070,7 @@ fn builds_mysql_unsigned_integer_column_with_length_before_attribute() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1104,6 +1109,7 @@ fn doris_table_editor_renames_column_without_mysql_change_syntax() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1167,6 +1173,7 @@ fn dameng_integer_column_omits_mysql_display_width() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1212,6 +1219,7 @@ fn builds_highgo_foreign_key_changes_with_postgres_syntax() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1288,6 +1296,7 @@ fn builds_informix_column_and_index_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1347,6 +1356,7 @@ fn oracle_does_not_generate_drop_sql_for_all_columns() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1422,6 +1432,7 @@ fn oracle_create_table_places_default_before_not_null() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1491,6 +1502,7 @@ fn oracle_create_table_preserves_character_length_units() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1529,6 +1541,7 @@ fn oracle_create_table_uses_unquoted_identifiers_for_new_objects() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1568,6 +1581,7 @@ fn oracle_create_table_leaves_uppercase_regular_identifier_unquoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1606,6 +1620,7 @@ fn oracle_create_table_quotes_special_and_reserved_identifiers() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1647,6 +1662,7 @@ fn oracle_create_table_distinguishes_new_and_referenced_foreign_key_identifiers(mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1689,6 +1705,7 @@ fn oracle_create_table_extracts_single_line_trigger_source_into_the_body() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1723,6 +1740,7 @@ fn oracle_create_table_warns_instead_of_emitting_an_unparsed_trigger_declarationmysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1761,6 +1779,7 @@ fn oracle_existing_quoted_identifiers_keep_exact_spelling() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1796,6 +1815,7 @@ fn oracle_new_identifier_formatting_does_not_change_other_dialects() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1893,6 +1913,7 @@ fn iris_drop_index_includes_table_name() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -1937,6 +1958,7 @@ fn iris_ignores_comment_changes_but_keeps_supported_column_alters() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2022,6 +2044,7 @@ fn oracle_compatible_databases_keep_comment_on_sql() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2059,6 +2082,7 @@ fn mysql_create_index_with_comment() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2095,6 +2119,7 @@ fn manticoresearch_builds_create_table_sql_only() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2141,6 +2166,7 @@ fn manticoresearch_builds_add_and_drop_column_sql() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2212,6 +2238,7 @@ fn gbase8a_uses_limited_mysql_ddl() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2285,6 +2312,7 @@ fn gbase8a_allows_mysql_style_column_reorder() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2329,6 +2357,7 @@ fn gbase8s_uses_informix_ddl_not_mysql() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2365,6 +2394,7 @@ fn gbase_without_driver_profile_still_uses_mysql_ddl() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2403,6 +2433,7 @@ fn manticoresearch_does_not_drop_id_column() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2474,6 +2505,7 @@ fn manticoresearch_warns_when_existing_column_properties_change() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2512,6 +2544,7 @@ fn manticoresearch_ignores_mysql_column_options() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2553,6 +2586,7 @@ fn manticoresearch_builds_text_column_properties() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2586,6 +2620,7 @@ fn manticoresearch_builds_json_secondary_index_property() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2615,6 +2650,7 @@ fn mysql_create_unique_index_with_comment_and_btree() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2646,6 +2682,7 @@ fn mysql_create_functional_index_preserves_key_part_syntax() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2677,6 +2714,7 @@ fn mysql_add_timestamp_column_drops_invalid_precision() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2708,6 +2746,7 @@ fn mysql_add_timestamp_column_preserves_valid_precision() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2746,6 +2785,7 @@ fn builds_postgres_create_table_with_comments_and_index() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2781,6 +2821,7 @@ fn quotes_expression_like_new_index_columns_without_provenance() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2856,6 +2897,7 @@ fn create_table_trims_table_name_whitespace_for_all_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2896,6 +2938,7 @@ fn warns_for_sqlite_unsafe_column_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -2942,6 +2985,7 @@ fn qualifies_attached_sqlite_table_and_index_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3014,6 +3058,7 @@ fn builds_rqlite_changes_with_sqlite_dialect() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3047,6 +3092,7 @@ fn builds_kingbase_add_column_without_column_keyword() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3115,6 +3161,7 @@ fn builds_mysql_column_reorder_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3174,6 +3221,7 @@ fn mysql_add_column_before_existing_column_does_not_reorder_shifted_column() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3240,6 +3288,7 @@ fn mysql_existing_column_reorder_does_not_reorder_columns_shifted_by_prior_move(mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3318,6 +3367,7 @@ fn mysql_moving_first_column_to_end_uses_single_reorder_statement() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3346,6 +3396,7 @@ fn builds_sql_server_quoted_column_and_index_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3380,6 +3431,7 @@ fn sqlserver_strips_mysql_display_width_from_fixed_integer_types() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3408,6 +3460,7 @@ fn sqlserver_strips_scale_from_float() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3436,6 +3489,7 @@ fn sqlserver_preserves_float_mantissa_bits() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3489,6 +3543,7 @@ fn sqlserver_default_changes_drop_old_constraints_with_isolated_batches() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3709,6 +3764,7 @@ fn sqlserver_unchanged_foreign_key_does_not_warn_when_saving_other_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3742,6 +3798,7 @@ fn sqlserver_add_column_with_identity() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3776,6 +3833,7 @@ fn sqlserver_legacy_column_comment_change_uses_legacy_extended_properties() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3812,6 +3870,7 @@ fn dameng_add_column_with_identity() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3839,6 +3898,7 @@ fn dameng_uppercases_lowercase_column_type() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3873,6 +3933,7 @@ fn dameng_rejects_identity_on_incompatible_type() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3909,6 +3970,7 @@ fn sqlserver_rejects_identity_on_incompatible_type() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3948,6 +4010,7 @@ fn sqlserver_changed_foreign_key_still_warns_as_unsupported() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -3992,6 +4055,7 @@ fn sqlserver_unchanged_identity_extra_does_not_mark_existing_column_changed() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4036,6 +4100,7 @@ fn dameng_unchanged_identity_extra_does_not_mark_existing_column_changed() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4293,6 +4358,7 @@ fn dameng_rejects_adding_second_identity_column() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4349,6 +4415,7 @@ fn sqlserver_existing_column_identity_change_warns_without_unchanged_foreign_keymysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4384,6 +4451,7 @@ fn builds_duckdb_create_table_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4508,6 +4576,7 @@ fn builds_clickhouse_nullable_comment_and_reorder_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -4558,6 +4627,7 @@ fn builds_h2_schema_qualified_existing_column_statements() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5606,6 +5676,7 @@ fn mysql_create_table_with_auto_increment() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5637,6 +5708,7 @@ fn mysql_create_table_keeps_column_charset_collation_and_comment() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5672,6 +5744,7 @@ fn mysql_compatible_databases_do_not_emit_mysql_column_charset_clauses() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5704,6 +5777,7 @@ fn mysql_create_table_with_on_update_current_timestamp() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5868,6 +5942,7 @@ fn postgres_create_table_with_identity() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5902,6 +5977,7 @@ fn dameng_create_table_with_identity() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5932,6 +6008,7 @@ fn dameng_create_table_preserves_character_length_units() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -5970,6 +6047,7 @@ fn dameng_alter_column_preserves_character_length_unit() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6009,6 +6087,7 @@ fn dameng_rejects_multiple_identity_columns() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6041,6 +6120,7 @@ fn dameng_rejects_zero_identity_increment() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6074,6 +6154,7 @@ fn sqlserver_create_table_with_identity() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6102,6 +6183,7 @@ fn mysql_quotes_datetime_literal_default() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6130,6 +6212,7 @@ fn mysql_does_not_quote_current_timestamp() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6159,6 +6242,7 @@ fn mysql_does_not_quote_temporal_function_with_parens() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6187,6 +6271,7 @@ fn mysql_date_literal_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6215,6 +6300,7 @@ fn mysql_time_literal_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6243,6 +6329,7 @@ fn non_temporal_types_are_not_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6375,6 +6462,7 @@ fn builds_mysql_foreign_key_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6408,6 +6496,7 @@ fn builds_mysql_composite_foreign_key() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6444,6 +6533,7 @@ fn builds_oracle_foreign_key_with_supported_actions() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6484,6 +6574,7 @@ fn builds_oracle_foreign_key_replacement() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6523,6 +6614,7 @@ fn builds_mysql_trigger_changes() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6553,6 +6645,7 @@ fn builds_sqlserver_trigger_with_multiple_events() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6599,6 +6692,7 @@ fn rebuilds_changed_sqlserver_trigger_from_complete_metadata_source() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6637,6 +6731,7 @@ fn sqlserver_trigger_edit_restores_disabled_state() {table_comment: None,original_table_comment: None,partitioned: false,+ foreign_table: false,mysql_engine: None,transwarp_create: None,is_gaussdb_m_mode: false,@@ -6685,6 +6780,7 @@ fn unchanged_postgres_trigger_does_not_block_column_rename() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6718,6 +6814,7 @@ fn changed_postgres_trigger_remains_unsupported() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6756,6 +6853,7 @@ fn rejects_editing_existing_oracle_trigger_without_complete_source() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6783,6 +6881,7 @@ fn builds_oracle_statement_trigger_without_row_clause() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6822,6 +6921,7 @@ fn drops_existing_oracle_trigger_without_reconstructing_it() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6846,6 +6946,7 @@ fn rejects_unsupported_oracle_compound_trigger_shape() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6874,6 +6975,7 @@ fn mysql_varchar_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6903,6 +7005,7 @@ fn mysql_char_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6933,6 +7036,7 @@ fn mysql_text_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6961,6 +7065,7 @@ fn mysql_enum_default_is_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -6989,6 +7094,7 @@ fn mysql_int_default_is_not_quoted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7127,6 +7233,7 @@ fn mysql_character_column_add_with_charset_collation() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7245,6 +7352,7 @@ fn mysql_numeric_column_omits_charset_collation_in_column_definition() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7291,6 +7399,7 @@ fn mysql_numeric_column_ignores_charset_collation_in_change_detection() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7332,6 +7441,7 @@ fn mysql_character_column_detects_charset_collation_change() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7378,6 +7488,7 @@ fn mysql_character_column_preserves_charset_collation_on_other_change() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7457,6 +7568,7 @@ fn mysql_inherited_column_charset_is_omitted_from_generated_ddl() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7504,6 +7616,7 @@ fn mysql_explicit_column_charset_survives_the_table_default_comparison() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7552,6 +7665,7 @@ fn mysql_inherited_column_charset_does_not_register_as_a_change() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7593,6 +7707,7 @@ fn mysql_collation_switched_away_from_the_table_default_is_emitted() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7639,6 +7754,7 @@ fn mysql_column_charset_switched_to_the_table_default_drops_the_clause() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7682,6 +7798,7 @@ fn mysql_column_charset_is_kept_when_the_table_default_is_unknown() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -7720,6 +7837,7 @@ fn mysql_create_table_omits_inherited_column_charset() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: Some("utf8mb4_0900_ai_ci".to_string()),});@@ -7873,6 +7991,7 @@ fn oscar_create_table_with_primary_key_and_comments() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8071,6 +8190,7 @@ fn oscar_drop_index_with_schema_qualifier() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8095,6 +8215,7 @@ fn oscar_table_comment_uses_comment_on_table() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8181,6 +8302,7 @@ fn postgres_partitioned_parent_concurrent_request_rejected() {mysql_engine: None,transwarp_create: None,partitioned: true,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8215,6 +8337,7 @@ fn postgres_partitioned_parent_plain_index_unchanged() {mysql_engine: None,transwarp_create: None,partitioned: true,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8261,6 +8384,7 @@ fn postgres_create_table_partitioned_concurrent_request_rejected() {mysql_engine: None,transwarp_create: None,partitioned: true,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8391,6 +8515,7 @@ fn postgres_create_table_concurrent_index() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8510,6 +8635,7 @@ fn gaussdb_m_options(columns: Vec<EditableStructureColumn>) -> TableStructureSqlmysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: true,table_collation: None,}@@ -8747,6 +8873,7 @@ fn gaussdb_m_rebuild_index_unchanged_type_does_not_rebuild() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: true,table_collation: None,};@@ -8797,6 +8924,7 @@ fn mysql_create_table_nullable_timestamp_without_default_gets_explicit_null() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8829,6 +8957,7 @@ fn mysql_create_table_nullable_timestamp_with_default_still_gets_explicit_null()mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8859,6 +8988,7 @@ fn mysql_create_table_nullable_datetime_does_not_gain_null_keyword() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});@@ -8889,6 +9019,7 @@ fn mysql_add_column_nullable_timestamp_without_default_gets_explicit_null() {mysql_engine: None,transwarp_create: None,partitioned: false,+ foreign_table: false,is_gaussdb_m_mode: false,table_collation: None,});diff --git a/crates/dbx-sql-schema/src/table_structure_sql/types.rs b/crates/dbx-sql-schema/src/table_structure_sql/types.rsindex 4d6a6bd3a5..1e66c5f992 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/types.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/types.rs@@ -254,6 +254,12 @@ pub struct TableStructureSqlOptions {/// will reject or downgrading to a blocking `CREATE INDEX`.#[serde(default)]pub partitioned: bool,+ /// Whether the target table is a PostgreSQL foreign table (`relkind = 'f'`).+ /// PostgreSQL rejects `COMMENT ON TABLE` for foreign tables+ /// (`"<name>" is not a table`), so the table-comment statement must use+ /// `COMMENT ON FOREIGN TABLE` when this is set.+ #[serde(default)]+ pub foreign_table: bool,/// When true, the connection is GaussDB M-mode which uses MySQL-compatible/// SQL dialect with backtick quoting. The structure editor maps this to/// `StructureDialect::Mysql` so that DDL is generated with MySQL syntax.