fix(oracle): export portable table DDL

This commit is contained in:
zipg authored and GitHub committed 2026-08-17 14:45:25 +08:00
1 parent 1cdee024c2
commit db7463eb70
13 files changed
+241 -30

No files matched your search

+2 -2
View File
@@ -2108,7 +2108,7 @@ pub async fn export_database_sql_core(
}
let ddl = if request.include_structure {
Some(
crate::schema::get_table_ddl_core(
crate::schema::get_table_export_ddl_core(
state,
&request.connection_id,
&request.database,
@@ -2266,7 +2266,7 @@ pub async fn export_database_sql_core(
{
Some(result) => result,
None => {
crate::schema::get_table_ddl_core(
crate::schema::get_table_export_ddl_core(
state,
&request.connection_id,
&request.database,
+14 -6
View File
@@ -2203,12 +2203,20 @@ impl AgentDriverClient {
table: &str,
timeout_duration: Option<Duration>,
) -> Result<T, String> {
self.call_method_with_timeout(
AgentMethod::GetTableDdl,
agent_schema_table_params(database, schema, table),
timeout_duration,
)
.await
self.get_table_ddl_with_options(database, schema, table, false, timeout_duration).await
}
pub async fn get_table_ddl_with_options<T: DeserializeOwned + Send + 'static>(
&mut self,
database: &str,
schema: &str,
table: &str,
portable: bool,
timeout_duration: Option<Duration>,
) -> Result<T, String> {
let mut params = agent_schema_table_params(database, schema, table);
params["portable"] = serde_json::json!(portable);
self.call_method_with_timeout(AgentMethod::GetTableDdl, params, timeout_duration).await
}
pub async fn execute_query<T: DeserializeOwned + Send + 'static>(&mut self, params: Value) -> Result<T, String> {
+19 -4
View File
@@ -6446,7 +6446,18 @@ pub async fn get_table_ddl_core(
table: &str,
object_type: Option<db::ObjectSourceKind>,
) -> Result<String, String> {
get_table_ddl_core_with_options(state, connection_id, database, schema, table, object_type, false).await
get_table_ddl_core_with_options(state, connection_id, database, schema, table, object_type, false, false).await
}
pub async fn get_table_export_ddl_core(
state: &AppState,
connection_id: &str,
database: &str,
schema: &str,
table: &str,
object_type: Option<db::ObjectSourceKind>,
) -> Result<String, String> {
get_table_ddl_core_with_options(state, connection_id, database, schema, table, object_type, false, true).await
}
pub async fn get_table_display_ddl_core(
@@ -6457,7 +6468,7 @@ pub async fn get_table_display_ddl_core(
table: &str,
object_type: Option<db::ObjectSourceKind>,
) -> Result<String, String> {
get_table_ddl_core_with_options(state, connection_id, database, schema, table, object_type, true).await
get_table_ddl_core_with_options(state, connection_id, database, schema, table, object_type, true, false).await
}
async fn get_table_ddl_core_with_options(
@@ -6468,6 +6479,7 @@ async fn get_table_ddl_core_with_options(
table: &str,
object_type: Option<db::ObjectSourceKind>,
include_postgres_access: bool,
portable_oracle: bool,
) -> Result<String, String> {
if crate::sql_dialect::parse_sqlserver_linked_schema_ref(schema).is_some() {
return Err("DDL is not supported for SQL Server linked server tables".to_string());
@@ -6513,7 +6525,7 @@ async fn get_table_ddl_core_with_options(
}
retry_metadata_connection(state, connection_id, Some(database), || {
get_table_ddl_once(state, connection_id, database, schema, table, include_postgres_access)
get_table_ddl_once(state, connection_id, database, schema, table, include_postgres_access, portable_oracle)
})
.await
}
@@ -6525,6 +6537,7 @@ async fn get_table_ddl_once(
schema: &str,
table: &str,
include_postgres_access: bool,
portable_oracle: bool,
) -> Result<String, String> {
let pool_key = state.get_or_create_metadata_pool_for_session(connection_id, Some(database), None).await?;
let db_config = connection_config(state, connection_id).await;
@@ -6604,6 +6617,7 @@ async fn get_table_ddl_once(
database,
schema,
table,
portable_oracle,
agent_metadata_timeout(db_config.as_ref()),
)
.await;
@@ -7712,10 +7726,11 @@ async fn oracle_agent_table_ddl(
database: &str,
schema: &str,
table: &str,
portable: bool,
timeout_duration: Option<Duration>,
) -> Result<String, String> {
let mut client = client.lock().await;
let ddl = client.get_table_ddl::<String>(database, schema, table, timeout_duration).await?;
let ddl = client.get_table_ddl_with_options::<String>(database, schema, table, portable, timeout_duration).await?;
match append_oracle_table_comment_ddl(&mut client, database, schema, table, &ddl, timeout_duration).await {
Ok(ddl) => Ok(ddl),
Err(error) => {
+12
View File
@@ -28,6 +28,7 @@ pub struct SchemaQuery {
pub apply_visible_filter: Option<bool>,
pub client_session_id: Option<String>,
pub include_postgres_access: Option<bool>,
pub portable: Option<bool>,
}
#[derive(Deserialize)]
@@ -646,6 +647,17 @@ pub async fn get_ddl(
dbx_core::schema::get_doris_catalog_table_ddl_core(&state.app, &q.connection_id, &catalog, database, table)
.await
.map_err(AppError::from)?
} else if q.portable.unwrap_or(false) {
dbx_core::schema::get_table_export_ddl_core(
&state.app,
&q.connection_id,
database,
schema,
table,
q.object_type,
)
.await
.map_err(AppError::from)?
} else if q.include_postgres_access.unwrap_or(false) {
dbx_core::schema::get_table_display_ddl_core(
&state.app,