Bind null custom types

This commit is contained in:
Billy Chan 2021-10-06 12:28:46 +08:00 committed by Chris Tsang
parent 125ee40161
commit 8990261d70
5 changed files with 13 additions and 13 deletions

View File

@ -30,7 +30,7 @@ futures-util = { version = "^0.3" }
log = { version = "^0.4", optional = true } log = { version = "^0.4", optional = true }
rust_decimal = { version = "^1", optional = true } rust_decimal = { version = "^1", optional = true }
sea-orm-macros = { version = "^0.2.4", path = "sea-orm-macros", optional = true } sea-orm-macros = { version = "^0.2.4", path = "sea-orm-macros", optional = true }
sea-query = { version = "^0.16.5", features = ["thread-safe"] } sea-query = { version = "^0.17.0", features = ["thread-safe"] }
sea-strum = { version = "^0.21", features = ["derive", "sea-orm"] } sea-strum = { version = "^0.21", features = ["derive", "sea-orm"] }
serde = { version = "^1.0", features = ["derive"] } serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1", optional = true } serde_json = { version = "^1", optional = true }

View File

@ -10,8 +10,8 @@ pub struct Model {
pub key: String, pub key: String,
pub value: String, pub value: String,
pub bytes: Vec<u8>, pub bytes: Vec<u8>,
pub date: Date, pub date: Option<Date>,
pub time: Time, pub time: Option<Time>,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -287,8 +287,8 @@ pub async fn create_metadata_table(db: &DbConn) -> Result<ExecResult, DbErr> {
.col(ColumnDef::new(metadata::Column::Key).string().not_null()) .col(ColumnDef::new(metadata::Column::Key).string().not_null())
.col(ColumnDef::new(metadata::Column::Value).string().not_null()) .col(ColumnDef::new(metadata::Column::Value).string().not_null())
.col(ColumnDef::new(metadata::Column::Bytes).binary().not_null()) .col(ColumnDef::new(metadata::Column::Bytes).binary().not_null())
.col(ColumnDef::new(metadata::Column::Date).date().not_null()) .col(ColumnDef::new(metadata::Column::Date).date())
.col(ColumnDef::new(metadata::Column::Time).time().not_null()) .col(ColumnDef::new(metadata::Column::Time).time())
.to_owned(); .to_owned();
create_table(db, &stmt, Metadata).await create_table(db, &stmt, Metadata).await

View File

@ -26,8 +26,8 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
key: "markup".to_owned(), key: "markup".to_owned(),
value: "1.18".to_owned(), value: "1.18".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
date: Date::from_ymd(2021, 9, 27), date: Some(Date::from_ymd(2021, 9, 27)),
time: Time::from_hms(11, 32, 55), time: Some(Time::from_hms(11, 32, 55)),
}, },
metadata::Model { metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
@ -35,8 +35,8 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
key: "exchange_rate".to_owned(), key: "exchange_rate".to_owned(),
value: "0.78".to_owned(), value: "0.78".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
date: Date::from_ymd(2021, 9, 27), date: Some(Date::from_ymd(2021, 9, 27)),
time: Time::from_hms(11, 32, 55), time: Some(Time::from_hms(11, 32, 55)),
}, },
metadata::Model { metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
@ -44,8 +44,8 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
key: "service_charge".to_owned(), key: "service_charge".to_owned(),
value: "1.1".to_owned(), value: "1.1".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
date: Date::from_ymd(2021, 9, 27), date: None,
time: Time::from_hms(11, 32, 55), time: None,
}, },
]; ];

View File

@ -24,8 +24,8 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
key: "markup".to_owned(), key: "markup".to_owned(),
value: "1.18".to_owned(), value: "1.18".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
date: Date::from_ymd(2021, 9, 27), date: Some(Date::from_ymd(2021, 9, 27)),
time: Time::from_hms(11, 32, 55), time: Some(Time::from_hms(11, 32, 55)),
}; };
let res = Metadata::insert(metadata.clone().into_active_model()) let res = Metadata::insert(metadata.clone().into_active_model())