Description
When using type alias for wrapped types trait TryFromU64 is not implemented
Steps to Reproduce
- Have a table with id you want to replace:
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveValueType)]
pub struct GroupId(i32);
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(schema_name = "public", table_name = "group")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: GroupId,
pub name: String,
pub description: Option<String>,
}
- change
i32 or other integer id type to an alias
pub type PgInt = i32;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveValueType)]
pub struct GroupId(PgInt);
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(schema_name = "public", table_name = "group")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: GroupId,
pub name: String,
pub description: Option<String>,
}
3. ERROR:
```rust
the trait bound IngredientGroupId: TryFromU64 is not satisfied
the following other types implement trait sea_orm::ActiveEnum:
AccessLevel
BatchSourceType
DataType
OperatorSign
UnitSystem
UploadStatus
VersionStatus
required for IngredientGroupId to implement TryFromU64 (rustc E0277)
Expected Behavior
A warning about unsupported types.
OR
this trait implemented the same way as in no alias case (might not be possible)
Actual Behavior
I get an error that the trait is not implemented by the derive macros.
Reproduces How Often
every time.
Workarounds
- just get rid of the alias all together.
- you could just implement it manually.
In my specific case I define all wrapper types with macros, which also handle aliases.
Fix suggestions
I didn't read the code yet, but I assume that this trait needs knowledge of underlying type and just reading them isn't possible as macros can't read them as of date.
So this bug is likely would require 2 things:
- Warning for unsupported types
- (Optional) A feature to specify underlying type
Versions
sea-orm = { version = "2.0.0-rc.31", features = [
"with-json",
"with-uuid",
"sqlx-postgres",
"runtime-tokio-native-tls",
"macros",
] }
Description
When using type alias for wrapped types trait
TryFromU64is not implementedSteps to Reproduce
i32or other integer id type to an aliasExpected Behavior
A warning about unsupported types.
OR
this trait implemented the same way as in no alias case (might not be possible)
Actual Behavior
I get an error that the trait is not implemented by the derive macros.
Reproduces How Often
every time.
Workarounds
In my specific case I define all wrapper types with macros, which also handle aliases.
Fix suggestions
I didn't read the code yet, but I assume that this trait needs knowledge of underlying type and just reading them isn't possible as macros can't read them as of date.
So this bug is likely would require 2 things:
Versions
sea-orm = { version = "2.0.0-rc.31", features = [
"with-json",
"with-uuid",
"sqlx-postgres",
"runtime-tokio-native-tls",
"macros",
] }