-
-
Notifications
You must be signed in to change notification settings - Fork 547
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Trait conflict when implementing IntoActiveModel<A>
outside of entity model definition
#547
Comments
facing the same issue :
error message :
|
@fairingrey if you define your implementation of trait in inside entity create the error will gone. I am still new to rust, but think this is related to orphan rule I guess. |
Hey @fairingrey, welcome! The So, we have... #[derive(Debug, DeriveIntoActiveModel)]
pub(crate) struct UpdateUser {
pub(crate) name: String,
pub(crate) email: String,
} |
Hey @koptan, you manage to solve the errors by moving the trait implementation inside entity crate? |
Thanks for the welcome 🙂 I know that works, but maybe more related to #322 -- Is it not possible for EDIT: Will also mention that moving |
Just as another question but in https://github.com/SeaQL/sea-orm/blob/master/src/entity/active_model.rs#L573-L599 I've patched it for my use case by including the following: impl IntoActiveValue<$ty> for Option<$ty> {
fn into_active_value(self) -> ActiveValue<$ty> {
match self {
Some(value) => Set(value),
None => NotSet,
}
}
} But I'm wondering if or why it wouldn't make sense. Is |
|
With the patch you made, I think it's good enough for your current use case. Btw... #492 might be helpful to you. |
I see. Regarding the patch, I'll definitely take a look at that (as I would like not to resort to my own patches if possible). Thanks for the quick responses! |
IntoActiveModel<A>
by handIntoActiveModel<A>
outside of entity model definition
I updated this issue to better reflect my original problem. You're free to close it if this is not the intended way of using the library, although it might be worth mentioning in the guides e.g. here |
Hi @billy1624 , Yes when I moved the trait implementation into entity create I was able to solve this issue. I think this is happening because we already have an implicit implementation for Again, I am still new to rust so maybe my feedback is so wrong. |
Oh,Seems to be at the wrong person. @koptan |
@baoyachi sorry my bad, I will modify the mention. |
@billy1624 I am still very confused. Shouldn't |
Yes, Did you spot something odd in the source code of SeaORM? Please point out the lines if there is any :) |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Description
Trying to implement
IntoActiveModel<A>
outside of my entity model definition gives the following error:I can't use
DeriveIntoActiveModel
either since I'm unaware how to specify (via attribute or etc) the specificActiveModelTrait
type that my type converts into since I define it outside of my crate.Steps to Reproduce
Expected Behavior
I expect it to be able to convert my type (defined outside of the entity crate) into an ActiveModel that I can use to update rows in my table.
Actual Behavior
Doesn't work as explained above.
Reproduces How Often
Always reproducible.
Versions
Database is Postgres 13.5, OS is ArchLinux 5.16.9-zen1-1-zen
Additional Information
Might be related to #322, #323, #340.
The text was updated successfully, but these errors were encountered: