From bde43f51f8f47bc6236104e0c57903b0181ac351 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Wed, 14 Sep 2022 22:51:05 -0700 Subject: [PATCH] Implement `IntoActiveValue` for `time` types. I tried to implement a [custom active model](https://www.sea-ql.org/SeaORM/docs/advanced-query/custom-active-model/), and one of the columns was `Option`. I got a compiler error: ``` error[E0277]: the trait bound `std::option::Option: IntoActiveValue<_>` is not satisfied ``` Looking into the source code, it seemed a simple oversight that this trait was implemented for the `chrono` types but not the `time` types, and it was easy enough to fix since there's already a macro to implement it for new types. I also noticed that the `time` types are not accounted for in `src/query/json.rs` while the `chrono` types are, which I assume is also an oversight. However, I don't have a need for that at this point and the fix for that seemed less trivial, so I'm just bringing it to your attention. Thanks for SeaORM! --- src/entity/active_model.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/entity/active_model.rs b/src/entity/active_model.rs index afc8bd28..cf679d96 100644 --- a/src/entity/active_model.rs +++ b/src/entity/active_model.rs @@ -719,6 +719,22 @@ impl_into_active_value!(crate::prelude::Decimal); #[cfg_attr(docsrs, doc(cfg(feature = "with-uuid")))] impl_into_active_value!(crate::prelude::Uuid); +#[cfg(feature = "with-time")] +#[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] +impl_into_active_value!(crate::prelude::TimeDate); + +#[cfg(feature = "with-time")] +#[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] +impl_into_active_value!(crate::prelude::TimeTime); + +#[cfg(feature = "with-time")] +#[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] +impl_into_active_value!(crate::prelude::TimeDateTime); + +#[cfg(feature = "with-time")] +#[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] +impl_into_active_value!(crate::prelude::TimeDateTimeWithTimeZone); + impl Default for ActiveValue where V: Into,