Skip to content

Commit

Permalink
fix: 修改 db fn create 为默认不过滤掉 id 列
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjing committed Aug 13, 2024
1 parent 3cbe2db commit b3aeea8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ sea-query-binder = { version = "0.6", features = [
"sqlx-postgres",
"with-uuid",
"with-chrono",
"with-rust_decimal",
] }
# -- Serde
serde = { version = "1", features = ["derive"] }
Expand Down
1 change: 0 additions & 1 deletion ultimates/ultimate-db/src/base/crud_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ where
let ctx = mm.ctx_ref()?;
// -- Extract fields (name / sea-query value expression)
let mut fields = data.not_none_sea_fields();
fields = SeaFields::new(fields.into_iter().filter(|f| f.iden.to_string() != "id").collect());
fields = prep_fields_for_create::<MC>(fields, ctx);

// -- Build query
Expand Down
6 changes: 6 additions & 0 deletions ultimates/ultimate-db/src/base/db_bmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ pub trait DbBmc {
fn has_optimistic_lock() -> bool {
false
}

/// 是否过滤用 column id
/// default: fals
fn filter_column_id() -> bool {
false
}
}
4 changes: 4 additions & 0 deletions ultimates/ultimate-db/src/base/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ where
fields = add_timestamps_for_create(fields, ctx);
}

if MC::filter_column_id() {
fields = SeaFields::new(fields.into_iter().filter(|f| f.iden.to_string() != "id").collect());
}

fields
}

Expand Down

0 comments on commit b3aeea8

Please sign in to comment.