You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a table locales with a single column id of text type, which is a primary key.
When I try to represent it as a new type like this:
use sea_orm::entity::prelude::*;#[derive(Clone,Debug,PartialEq,DeriveEntityModel)]#[sea_orm(table_name = "locales")]pubstructModel{#[sea_orm(primary_key, auto_increment = false)]pubid:Locale,}#[derive(Copy,Clone,Debug,EnumIter,DeriveRelation)]pubenumRelation{}implActiveModelBehaviorforActiveModel{}#[derive(Clone,Debug,PartialEq,DeriveValueType)]pubstructLocale(String);
I get an error:
│error[E0277]: the trait bound `Locale: sea_orm::ActiveEnum` is not satisfied │
│ --> core/models/src/locale.rs:7:13 │
│ | │
│7 | pub id: Locale, │
│ | ^^^^^^ the trait `sea_orm::ActiveEnum` is not implemented for `Locale` │
│ | │
│ = help: the following other types implement trait `TryFromU64`: │
│ (T0, T1) │
│ (T0, T1, T2) │
│ (T0, T1, T2, T3) │
│ (T0, T1, T2, T3, T4) │
│ (T0, T1, T2, T3, T4, T5) │
│ (T0, T1, T2, T3, T4, T5, T6) │
│ (T0, T1, T2, T3, T4, T5, T6, T7) │
│ (T0, T1, T2, T3, T4, T5, T6, T7, T8) │
│ and 29 others │
│ = note: required for `Locale` to implement `TryFromU64` │
│note: required by a bound in `sea_orm::PrimaryKeyTrait::ValueType` │
│ --> /Users/Alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sea-orm-0.12.2/src/entity/primary_key.rs:49:11 │
│ | │
│49 | + TryFromU64; │
│ | ^^^^^^^^^^ required by this bound in `PrimaryKeyTrait::ValueType`
Deriver DerivePrimaryKey accepts enums only. I'm not sure why a primary key must be an enum.
Also, I tried to implement all the traits manually, but ended up with requirement to implement Iterator for the newtype, which doesn't make sense either.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I have a table
localeswith a single columnidoftexttype, which is a primary key.When I try to represent it as a new type like this:
I get an error:
Deriver
DerivePrimaryKeyaccepts enums only. I'm not sure why a primary key must be an enum.Also, I tried to implement all the traits manually, but ended up with requirement to implement Iterator for the newtype, which doesn't make sense either.
All reactions