Naivedatetime for placed_at on order (#40)
* WIP use NativeDateTime for placed_at * Use NaiveDatetime for placed_at * Cargo fmt again Co-authored-by: Chris Tsang <tyt2y7@gmail.com>
This commit is contained in:
parent
6ff5a32b7a
commit
a838cf7c23
@ -1,4 +1,5 @@
|
||||
use crate::DbErr;
|
||||
use chrono::NaiveDateTime;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -163,6 +164,7 @@ try_getable_mysql!(u64);
|
||||
try_getable_all!(f32);
|
||||
try_getable_all!(f64);
|
||||
try_getable_all!(String);
|
||||
try_getable_all!(NaiveDateTime);
|
||||
|
||||
#[cfg(feature = "with-rust_decimal")]
|
||||
use rust_decimal::Decimal;
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use rust_decimal::prelude::*;
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
@ -16,7 +17,7 @@ pub struct Model {
|
||||
pub total: Decimal,
|
||||
pub bakery_id: Option<i32>,
|
||||
pub customer_id: Option<i32>,
|
||||
pub placed_at: String,
|
||||
pub placed_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||||
|
@ -1,4 +1,5 @@
|
||||
pub use super::*;
|
||||
use chrono::offset::Utc;
|
||||
use rust_decimal_macros::dec;
|
||||
|
||||
pub async fn test_create_lineitem(db: &DbConn) {
|
||||
@ -64,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("placeholder".to_string()),
|
||||
placed_at: Set(Some(Utc::now().naive_utc())),
|
||||
..Default::default()
|
||||
};
|
||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
||||
|
@ -1,4 +1,5 @@
|
||||
pub use super::*;
|
||||
use chrono::offset::Utc;
|
||||
use rust_decimal_macros::dec;
|
||||
|
||||
pub async fn test_create_order(db: &DbConn) {
|
||||
@ -65,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("placeholder".to_string()),
|
||||
placed_at: Set(Some(Utc::now().naive_utc())),
|
||||
..Default::default()
|
||||
};
|
||||
let order_insert_res: InsertResult = Order::insert(order_1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user