feat(grid): support deleting rows from JOIN query results

This commit is contained in:
zipg authored and GitHub committed 2026-08-27 16:28:14 +08:00
1 parent 36a7b7bd3a
commit 920ab62cf1
7 files changed
+207 -4

No files matched your search

+35
View File
@@ -6175,6 +6175,41 @@ mod tests {
assert!(result.rollback_statements.iter().any(|statement| statement.contains(r#"WHERE "ID" = 101"#)));
}
#[test]
fn mysql_join_result_delete_targets_only_the_resolved_source_primary_key() {
let result = prepare_data_grid_save(DataGridSaveStatementOptions {
database_type: Some(DatabaseType::Mysql),
identifier_quote: None,
table_meta: DataGridTableMeta {
catalog: None,
database: None,
schema: Some("lims".to_string()),
table_name: "lims_batchs_simple".to_string(),
primary_keys: vec!["id".to_string()],
columns: Some(vec![
column("id", "bigint", false, None),
column("sno", "integer", true, None),
column("batchs_id", "bigint", false, None),
column("simple_id", "bigint", false, None),
]),
},
columns: vec!["id".to_string(), "sno".to_string(), "batchs_id".to_string(), "simple_id".to_string()],
source_columns: Some(vec![
Some("id".to_string()),
Some("sno".to_string()),
Some("batchs_id".to_string()),
Some("simple_id".to_string()),
]),
rows: vec![vec![json!(2658055), json!(4), json!(57485), json!(492045)]],
dirty_rows: vec![],
deleted_rows: vec![0],
new_rows: vec![],
});
assert_eq!(result.validation_error, None);
assert_eq!(result.statements, vec!["DELETE FROM `lims`.`lims_batchs_simple` WHERE `id` = 2658055;"]);
}
#[test]
fn prepares_oracle_timestamp_insert_from_iso_grid_value() {
let result = prepare_data_grid_save(DataGridSaveStatementOptions {