From 9c50cc789b2723058c22f483123563d201a2c845 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Aug 2026 00:10:11 +0800 Subject: [PATCH] fix(gaussdb): use schema for M-mode view DDL --- crates/dbx-core/src/schema.rs | 38 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs index 2c128b8064..637dece85c 100644 --- a/crates/dbx-core/src/schema.rs +++ b/crates/dbx-core/src/schema.rs @@ -2998,22 +2998,41 @@ mod tests { config.driver_profile = Some("gaussdb-m".to_string()); assert_eq!( - gaussdb_m_view_object_source_sql(&config, "tenant`db", "active`users", &db::ObjectSourceKind::View) - .as_deref(), - Some("SHOW CREATE VIEW `tenant``db`.`active``users`") + gaussdb_m_view_object_source_sql( + &config, + "connection_db", + "tenant`schema", + "active`users", + &db::ObjectSourceKind::View, + ) + .as_deref(), + Some("SHOW CREATE VIEW `tenant``schema`.`active``users`") ); assert_eq!( - gaussdb_m_view_object_source_sql(&config, "", "active`users", &db::ObjectSourceKind::View).as_deref(), + gaussdb_m_view_object_source_sql(&config, "connection_db", "", "active`users", &db::ObjectSourceKind::View) + .as_deref(), Some("SHOW CREATE VIEW `active``users`") ); assert_eq!( - gaussdb_m_view_object_source_sql(&config, "tenant_db", "refresh_users", &db::ObjectSourceKind::Function), + gaussdb_m_view_object_source_sql( + &config, + "connection_db", + "tenant_schema", + "refresh_users", + &db::ObjectSourceKind::Function, + ), None ); config.driver_profile = Some("gaussdb".to_string()); assert_eq!( - gaussdb_m_view_object_source_sql(&config, "tenant_db", "active_users", &db::ObjectSourceKind::View), + gaussdb_m_view_object_source_sql( + &config, + "connection_db", + "tenant_schema", + "active_users", + &db::ObjectSourceKind::View, + ), None ); } @@ -6783,12 +6802,13 @@ fn external_driver_uses_mysql_ddl(config: &ConnectionConfig) -> bool { fn gaussdb_m_view_object_source_sql( config: &ConnectionConfig, - database: &str, + _database: &str, + schema: &str, name: &str, kind: &db::ObjectSourceKind, ) -> Option { (gaussdb_uses_m_jdbc_driver(config) && matches!(kind, db::ObjectSourceKind::View)) - .then(|| mysql_object_source_sql(database, name, kind)) + .then(|| mysql_object_source_sql(schema, name, kind)) } fn mysql_external_driver_ddl_sql(database: &str, schema: &str, table: &str) -> String { @@ -7427,7 +7447,7 @@ async fn get_object_source_once( let config = config.clone(); let session = session.clone(); drop(connections); - if let Some(sql) = gaussdb_m_view_object_source_sql(config.as_ref(), database, name, &object_type) { + if let Some(sql) = gaussdb_m_view_object_source_sql(config.as_ref(), database, schema, name, &object_type) { let result: db::QueryResult = session .invoke_with_timeout( "executeQuery",