feat(export): add DB2 comments to XLSX headers
This commit is contained in:
35 files changed
+640
-87
No files matched your search
@@ -61,6 +61,8 @@ pub struct TableExportRequest {
|
||||
pub date_time_format: Option<String>,
|
||||
#[serde(default)]
|
||||
pub numeric_column_right_align: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub column_comments: Option<Vec<Option<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@@ -765,6 +767,7 @@ async fn try_export_native_table_stream(
|
||||
}
|
||||
"xlsx" => {
|
||||
let xlsx_column_types = export_column_types(request);
|
||||
let column_comments: Vec<Option<String>> = request.column_comments.clone().unwrap_or_default();
|
||||
let xlsx_file =
|
||||
std::fs::File::create(&request.file_path).map_err(|e| format!("Failed to create XLSX file: {e}"))?;
|
||||
let mut writer = start_streaming_xlsx_workbook_with_options(
|
||||
@@ -772,6 +775,7 @@ async fn try_export_native_table_stream(
|
||||
Some(&request.table_name),
|
||||
col_names,
|
||||
&xlsx_column_types,
|
||||
&column_comments,
|
||||
&[],
|
||||
request.date_time_format.as_deref(),
|
||||
request.numeric_column_right_align,
|
||||
@@ -1389,6 +1393,7 @@ async fn export_table_data_core_inner(
|
||||
}
|
||||
"xlsx" => {
|
||||
let xlsx_column_types = export_column_types(request);
|
||||
let column_comments: Vec<Option<String>> = request.column_comments.clone().unwrap_or_default();
|
||||
// Create a dedicated file handle for the streaming XLSX writer
|
||||
// instead of cloning the outer BufWriter's handle. This avoids
|
||||
// sharing a file descriptor between two independent buffers.
|
||||
@@ -1399,6 +1404,7 @@ async fn export_table_data_core_inner(
|
||||
Some(&request.table_name),
|
||||
&col_names,
|
||||
&xlsx_column_types,
|
||||
&column_comments,
|
||||
&[],
|
||||
request.date_time_format.as_deref(),
|
||||
request.numeric_column_right_align,
|
||||
@@ -1880,6 +1886,7 @@ mod tests {
|
||||
row_limit,
|
||||
date_time_format: None,
|
||||
numeric_column_right_align: false,
|
||||
column_comments: None,
|
||||
};
|
||||
|
||||
ExternalDriverExportFixture { state, request, calls, output, dir }
|
||||
@@ -2041,6 +2048,7 @@ mod tests {
|
||||
row_limit: Some(1000),
|
||||
date_time_format: None,
|
||||
numeric_column_right_align: false,
|
||||
column_comments: None,
|
||||
};
|
||||
|
||||
let sql = table_cursor_sql(
|
||||
@@ -2090,6 +2098,7 @@ mod tests {
|
||||
row_limit: None,
|
||||
date_time_format: None,
|
||||
numeric_column_right_align: false,
|
||||
column_comments: None,
|
||||
};
|
||||
let sql = table_cursor_sql(&request, &DatabaseType::Oracle, &columns, &primary_keys);
|
||||
assert_eq!(sql, "SELECT \"ID\", \"NAME\" FROM \"APP\".\"USERS\"");
|
||||
@@ -2403,6 +2412,7 @@ mod tests {
|
||||
sheet_name: Some("employees".to_string()),
|
||||
columns: vec!["id".to_string(), "name".to_string(), "salary".to_string()],
|
||||
column_types: vec![],
|
||||
column_comments: vec![],
|
||||
rows: vec![
|
||||
vec![json!(1), json!("Alice"), json!(75000.50)],
|
||||
vec![json!(2), json!("Bob"), json!(82000)],
|
||||
|
||||
Reference in new issue
Block a user