Skip to content

Commit

Permalink
fix insertion bug with database default fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtbuilds committed Oct 17, 2024
1 parent 3bad2fa commit fbc2c39
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions macro/src/codegen/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ pub fn impl_Model__insert(db: &dyn OrmliteCodegen, attr: &TableMeta, metadata_ca
let mut placeholder = db.placeholder();
let db = db.database_ts();
let table = &attr.name;
let params = attr.database_columns().map(|_| placeholder.next().unwrap());
let params = attr.database_columns().map(|c| {
if c.has_database_default {
"DEFAULT".to_string()
} else {
placeholder.next().unwrap()
}
});

let query_bindings = attr.database_columns().map(|c| insertion_binding(c));
let query_bindings = attr
.database_columns()
.filter(|c| !c.has_database_default)
.map(|c| insertion_binding(c));

let insert_join = attr.many_to_one_joins().map(|c| insert_join(c));

Expand Down

0 comments on commit fbc2c39

Please sign in to comment.