-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement IntoActiveValue
for time
types.
#1041
Conversation
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<TimeDateTimeWithTimeZone>`. I got a compiler error: ``` error[E0277]: the trait bound `std::option::Option<sea_orm::prelude::TimeDateTimeWithTimeZone>: 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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jimmycuadra, thanks for the report and the PR!!
Yes, this is an oversight. And I want to prevent this from happening again by adding test cases and leave a note for all other developers. Please check and merge jimmycuadra#1.
Also, I will address the serialization of time
types as serde_json::Value
at #1042.
Thank you for the fast response! I've merged your PR into my branch. |
Thank you |
Implement `IntoActiveValue` for `time` types.
I tried to implement a custom active model, and one of the columns was
Option<TimeDateTimeWithTimeZone>
. I got a compiler error:Looking into the source code, it seemed a simple oversight that this trait was implemented for the
chrono
types but not thetime
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 insrc/query/json.rs
while thechrono
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!