Support chrono::NaiveTime
This commit is contained in:
parent
f7e96b3d72
commit
02066cef6e
@ -171,7 +171,7 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec<Attribute>) -> syn::Res
|
|||||||
"f64" => quote! { Double },
|
"f64" => quote! { Double },
|
||||||
"bool" => quote! { Boolean },
|
"bool" => quote! { Boolean },
|
||||||
"Date" | "NaiveDate" => quote! { Date },
|
"Date" | "NaiveDate" => quote! { Date },
|
||||||
"NaiveTime" => quote! { Time },
|
"Time" | "NaiveTime" => quote! { Time },
|
||||||
"DateTime" | "NaiveDateTime" => {
|
"DateTime" | "NaiveDateTime" => {
|
||||||
quote! { DateTime }
|
quote! { DateTime }
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ pub use serde_json::Value as Json;
|
|||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
pub use chrono::NaiveDate as Date;
|
pub use chrono::NaiveDate as Date;
|
||||||
|
|
||||||
|
#[cfg(feature = "with-chrono")]
|
||||||
|
pub use chrono::NaiveTime as Time;
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
pub use chrono::NaiveDateTime as DateTime;
|
pub use chrono::NaiveDateTime as DateTime;
|
||||||
|
|
||||||
|
@ -244,6 +244,9 @@ try_getable_all!(serde_json::Value);
|
|||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
try_getable_all!(chrono::NaiveDate);
|
try_getable_all!(chrono::NaiveDate);
|
||||||
|
|
||||||
|
#[cfg(feature = "with-chrono")]
|
||||||
|
try_getable_all!(chrono::NaiveTime);
|
||||||
|
|
||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
try_getable_all!(chrono::NaiveDateTime);
|
try_getable_all!(chrono::NaiveDateTime);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ pub struct Model {
|
|||||||
pub value: String,
|
pub value: String,
|
||||||
pub bytes: Vec<u8>,
|
pub bytes: Vec<u8>,
|
||||||
pub date: Date,
|
pub date: Date,
|
||||||
|
pub time: Time,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
@ -287,6 +287,7 @@ pub async fn create_metadata_table(db: &DbConn) -> Result<ExecResult, DbErr> {
|
|||||||
.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().not_null())
|
||||||
|
.col(ColumnDef::new(metadata::Column::Time).time().not_null())
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
create_table(db, &stmt, Metadata).await
|
create_table(db, &stmt, Metadata).await
|
||||||
|
@ -26,6 +26,7 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
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: Date::from_ymd(2021, 9, 27),
|
||||||
|
time: Time::from_hms(11, 32, 55),
|
||||||
},
|
},
|
||||||
metadata::Model {
|
metadata::Model {
|
||||||
uuid: Uuid::new_v4(),
|
uuid: Uuid::new_v4(),
|
||||||
@ -33,6 +34,7 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
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: Date::from_ymd(2021, 9, 27),
|
||||||
|
time: Time::from_hms(11, 32, 55),
|
||||||
},
|
},
|
||||||
metadata::Model {
|
metadata::Model {
|
||||||
uuid: Uuid::new_v4(),
|
uuid: Uuid::new_v4(),
|
||||||
@ -40,6 +42,7 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
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: Date::from_ymd(2021, 9, 27),
|
||||||
|
time: Time::from_hms(11, 32, 55),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
|
|||||||
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: Date::from_ymd(2021, 9, 27),
|
||||||
|
time: Time::from_hms(11, 32, 55),
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = Metadata::insert(metadata.clone().into_active_model())
|
let res = Metadata::insert(metadata.clone().into_active_model())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user