-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
> 0.10.2: error[E0119]: conflicting implementations of trait #1287
Comments
Hey @frederikhors, thanks for the reporting!! I want to understand the situation before formulating the solution. I guess the schema is similar to above? There are two paths between
cake entity file:use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
#[sea_orm(column_type = "Decimal(Some((19, 4)))")]
pub price: Decimal,
pub bakery_id: Option<i32>,
pub gluten_free: bool,
pub serial: Uuid,
pub recipe_author: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::baker::Entity",
from = "Column::RecipeAuthor",
to = "super::baker::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Baker,
#[sea_orm(
belongs_to = "super::bakery::Entity",
from = "Column::BakeryId",
to = "super::bakery::Column::Id",
on_update = "NoAction",
on_delete = "NoAction"
)]
Bakery,
#[sea_orm(has_many = "super::lineitem::Entity")]
Lineitem,
}
impl Related<super::bakery::Entity> for Entity {
fn to() -> RelationDef {
Relation::Bakery.def()
}
}
impl Related<super::lineitem::Entity> for Entity {
fn to() -> RelationDef {
Relation::Lineitem.def()
}
}
impl Related<super::baker::Entity> for Entity { // Conflicting implementation!!
fn to() -> RelationDef {
Relation::Baker.def()
}
}
impl Related<super::baker::Entity> for Entity { // Conflicting implementation!!
fn to() -> RelationDef {
super::cakes_bakers::Relation::Baker.def()
}
fn via() -> Option<RelationDef> {
Some(super::cakes_bakers::Relation::Cake.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {}
baker entity file:use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "baker")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub name: String,
pub contact_details: Json,
pub bakery_id: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::bakery::Entity",
from = "Column::BakeryId",
to = "super::bakery::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Bakery,
#[sea_orm(has_many = "super::cake::Entity")]
Cake,
}
impl Related<super::bakery::Entity> for Entity {
fn to() -> RelationDef {
Relation::Bakery.def()
}
}
impl Related<super::cake::Entity> for Entity { // Conflicting implementation!!
fn to() -> RelationDef {
Relation::Cake.def()
}
}
impl Related<super::cake::Entity> for Entity { // Conflicting implementation!!
fn to() -> RelationDef {
super::cakes_bakers::Relation::Cake.def()
}
fn via() -> Option<RelationDef> {
Some(super::cakes_bakers::Relation::Baker.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {} |
Yeah. I think the issue is because we have |
I think I'm seeing something similar on 0.10.*. I was previously using 0.9.0 without issue.
Imports and macro for the file in question: use sea_orm::{entity::prelude::*, strum::Display};
use serde::{Deserialize, Serialize};
#[derive(
Debug, Display, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Deserialize, Serialize,
)] Downgrading to 0.9.3 solves the issue. Let me know if you'd like me to open a separate issue @billy1624. |
I think this is not the same. |
I was talking about this in the discord a bit. The generator seems to generate all relations as You can manually code the solution to this with, I believe, Chained Relations, so in the example could do:
So the default relationship from Cake will give you its recipe author. To get its bakers, you use Short term maybe the generator should generate And long term, maybe make it customizable for how the user wants to handle relationships. For example, I think I'd like the ability to generate all relationships as |
Hey @TurtIeSocks, the problem you mention isn't related to this issue. In sea-orm 0.10.x, |
Hey everyone, thanks for the input! I've created #1298 which will skip the implementation of impl Related<super::baker::Entity> for Entity {
fn to() -> RelationDef {
Relation::Baker.def()
}
} While keeping this impl Related<super::baker::Entity> for Entity {
fn to() -> RelationDef {
super::cakes_bakers::Relation::Baker.def()
}
fn via() -> Option<RelationDef> {
Some(super::cakes_bakers::Relation::Cake.def().rev())
}
} |
Can you release this ASAP? |
I'll publish it tomorrow morning |
sea-orm-cli 0.10.6 has been published |
Description
Using unfortunately on a new PC the new
sea-orm-cli@0.10.5
instead of0.10.2
I get the below error with the same PG schema.I cannot publish code because of NDA.
Actual Behavior
It gives this error after generation:
Versions
The text was updated successfully, but these errors were encountered: