ValueType does not need to impl Default
This commit is contained in:
parent
a838cf7c23
commit
1e6a778a0f
@ -71,7 +71,11 @@ pub fn expand_derive_active_model(ident: Ident, data: Data) -> syn::Result<Token
|
||||
|
||||
fn take(&mut self, c: <Self::Entity as EntityTrait>::Column) -> sea_orm::ActiveValue<sea_orm::Value> {
|
||||
match c {
|
||||
#(<Self::Entity as EntityTrait>::Column::#name => std::mem::take(&mut self.#field).into_wrapped_value(),)*
|
||||
#(<Self::Entity as EntityTrait>::Column::#name => {
|
||||
let mut value = sea_orm::ActiveValue::unset();
|
||||
std::mem::swap(&mut value, &mut self.#field);
|
||||
value.into_wrapped_value()
|
||||
},)*
|
||||
_ => sea_orm::ActiveValue::unset(),
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ pub struct Model {
|
||||
pub total: Decimal,
|
||||
pub bakery_id: Option<i32>,
|
||||
pub customer_id: Option<i32>,
|
||||
pub placed_at: Option<NaiveDateTime>,
|
||||
pub placed_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||||
|
@ -65,7 +65,7 @@ pub async fn test_create_lineitem(db: &DbConn) {
|
||||
let order_1 = order::ActiveModel {
|
||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||
customer_id: Set(Some(customer_insert_res.last_insert_id as i32)),
|
||||
placed_at: Set(Some(Utc::now().naive_utc())),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
||||
|
@ -66,7 +66,7 @@ pub async fn test_create_order(db: &DbConn) {
|
||||
bakery_id: Set(Some(bakery_insert_res.last_insert_id as i32)),
|
||||
customer_id: Set(Some(customer_insert_res.last_insert_id as i32)),
|
||||
total: Set(dec!(15.10)),
|
||||
placed_at: Set(Some(Utc::now().naive_utc())),
|
||||
placed_at: Set(Utc::now().naive_utc()),
|
||||
..Default::default()
|
||||
};
|
||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user