feat(db2): enable table data imports
This commit is contained in:
5 files changed
+82
-3
No files matched your search
@@ -323,6 +323,10 @@ describe("supportsTableVacuum", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("supportsTableImport", () => {
|
describe("supportsTableImport", () => {
|
||||||
|
it("enables DB2 table import", () => {
|
||||||
|
expect(supportsTableImport("db2")).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("enables OceanBase Oracle table import", () => {
|
it("enables OceanBase Oracle table import", () => {
|
||||||
expect(supportsTableImport("oceanbase-oracle")).toBe(true);
|
expect(supportsTableImport("oceanbase-oracle")).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2044,7 +2044,7 @@
|
|||||||
"diagram": true,
|
"diagram": true,
|
||||||
"tableDataEdit": true,
|
"tableDataEdit": true,
|
||||||
"tableStructureEdit": false,
|
"tableStructureEdit": false,
|
||||||
"tableImport": false,
|
"tableImport": true,
|
||||||
"dataTransfer": false,
|
"dataTransfer": false,
|
||||||
"sqlFileExecution": true,
|
"sqlFileExecution": true,
|
||||||
"databaseCreate": false,
|
"databaseCreate": false,
|
||||||
|
|||||||
@@ -5231,7 +5231,7 @@ fn infer_column_type(rows: &[Vec<serde_json::Value>], source_index: usize) -> Im
|
|||||||
fn text_data_type(db_type: &DatabaseType) -> &'static str {
|
fn text_data_type(db_type: &DatabaseType) -> &'static str {
|
||||||
match db_type {
|
match db_type {
|
||||||
DatabaseType::SqlServer => "NVARCHAR(MAX)",
|
DatabaseType::SqlServer => "NVARCHAR(MAX)",
|
||||||
DatabaseType::Oracle | DatabaseType::OceanbaseOracle | DatabaseType::Dameng => "CLOB",
|
DatabaseType::Oracle | DatabaseType::OceanbaseOracle | DatabaseType::Dameng | DatabaseType::Db2 => "CLOB",
|
||||||
DatabaseType::ClickHouse => "String",
|
DatabaseType::ClickHouse => "String",
|
||||||
DatabaseType::Hive
|
DatabaseType::Hive
|
||||||
| DatabaseType::Transwarp
|
| DatabaseType::Transwarp
|
||||||
@@ -12035,6 +12035,29 @@ mod tests {
|
|||||||
assert_eq!(plan.sql, "CREATE TABLE [dbo].[events] (\n [notes] NVARCHAR(MAX)\n)");
|
assert_eq!(plan.sql, "CREATE TABLE [dbo].[events] (\n [notes] NVARCHAR(MAX)\n)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn db2_create_table_plan_uses_clob_for_inferred_text() {
|
||||||
|
let data = ParsedImportFile {
|
||||||
|
columns: vec!["id".to_string(), "notes".to_string()],
|
||||||
|
rows: vec![vec![serde_json::json!(1), serde_json::json!("long text")]],
|
||||||
|
total_rows: 1,
|
||||||
|
effective_encoding: None,
|
||||||
|
};
|
||||||
|
let mappings = data
|
||||||
|
.columns
|
||||||
|
.iter()
|
||||||
|
.map(|column| TableImportColumnMapping {
|
||||||
|
source_column: column.clone(),
|
||||||
|
target_column: column.clone(),
|
||||||
|
target_data_type: None,
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let plan = build_import_create_table_plan(&data, &mappings, "events", "APP", &DatabaseType::Db2).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(plan.sql, "CREATE TABLE \"APP\".\"events\" (\n \"id\" BIGINT,\n \"notes\" CLOB\n)");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_table_plan_uses_sqlserver_float_for_inferred_decimals() {
|
fn create_table_plan_uses_sqlserver_float_for_inferred_decimals() {
|
||||||
let data = ParsedImportFile {
|
let data = ParsedImportFile {
|
||||||
@@ -12202,6 +12225,50 @@ mod tests {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn db2_import_uses_schema_qualified_multi_row_insert() {
|
||||||
|
let mappings = vec![
|
||||||
|
TableImportColumnMapping {
|
||||||
|
source_column: "id".to_string(),
|
||||||
|
target_column: "ID".to_string(),
|
||||||
|
target_data_type: None,
|
||||||
|
},
|
||||||
|
TableImportColumnMapping {
|
||||||
|
source_column: "name".to_string(),
|
||||||
|
target_column: "NAME".to_string(),
|
||||||
|
target_data_type: None,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
let data = ParsedImportFile {
|
||||||
|
columns: vec!["id".to_string(), "name".to_string()],
|
||||||
|
rows: vec![
|
||||||
|
vec![serde_json::json!(1), serde_json::json!("Ada")],
|
||||||
|
vec![serde_json::json!(2), serde_json::json!("Grace")],
|
||||||
|
],
|
||||||
|
total_rows: 2,
|
||||||
|
effective_encoding: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let batches = build_import_insert_batches(
|
||||||
|
&data,
|
||||||
|
&mappings,
|
||||||
|
&[("ID".to_string(), "BIGINT".to_string()), ("NAME".to_string(), "VARCHAR(128)".to_string())],
|
||||||
|
"USERS",
|
||||||
|
"APP",
|
||||||
|
&DatabaseType::Db2,
|
||||||
|
500,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
batches,
|
||||||
|
vec![ImportSqlBatch {
|
||||||
|
sql: "INSERT INTO \"APP\".\"USERS\" (\"ID\", \"NAME\") VALUES\n(1, 'Ada'),\n(2, 'Grace')".to_string(),
|
||||||
|
row_count: 2,
|
||||||
|
}]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transwarp_import_batches_preserve_values_across_multiple_statements() {
|
fn transwarp_import_batches_preserve_values_across_multiple_statements() {
|
||||||
let mappings = vec!["id", "label", "payload"]
|
let mappings = vec!["id", "label", "payload"]
|
||||||
|
|||||||
@@ -512,3 +512,11 @@ fn xugu_declares_table_import_support() {
|
|||||||
|
|
||||||
assert!(xugu.capabilities.table_import);
|
assert!(xugu.capabilities.table_import);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn db2_declares_table_import_support() {
|
||||||
|
let manifest = driver_manifest();
|
||||||
|
let db2 = manifest.drivers.iter().find(|driver| driver.db_type == DatabaseType::Db2).expect("DB2 manifest entry");
|
||||||
|
|
||||||
|
assert!(db2.capabilities.table_import);
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ capabilities:
|
|||||||
diagram: true
|
diagram: true
|
||||||
tableDataEdit: true
|
tableDataEdit: true
|
||||||
tableStructureEdit: false
|
tableStructureEdit: false
|
||||||
tableImport: false
|
tableImport: true
|
||||||
dataTransfer: false
|
dataTransfer: false
|
||||||
sqlFileExecution: true
|
sqlFileExecution: true
|
||||||
databaseCreate: false
|
databaseCreate: false
|
||||||
|
|||||||
Reference in new issue
Block a user