-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
Model with Generics #402
Comments
❄️🎄 |
With #400 you could define the following: #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "model")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: AccountId<String>,
pub name: String,
} But not... #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "model")]
pub struct Model<T> {
#[sea_orm(primary_key)]
pub id: AccountId<T>,
pub name: String,
} So, I'm think should we also support the use of generics over Model? @tyt2y3 |
PR #400 works perfectly for my usecase. Thanks, @billy1624. |
I am working on a crate called
async-graphql-relay
and have recently redone the public API to make it less cumbersome to use (you can checkout the example folder in the repo). When doing this I introduced a typeRelayNodeID
which is generic on the Model so it is declared asRelayNodeID<Self>
. This is done so that among other things all ID's returned from GraphQL are globally unique and contain information about the specific type they are. This type is a wrapper around a standard Uuidv4 and from a database perspective should be treated this way.After chatting with @billy1624 he pointed me towards this resource which shows how to implement
sea-orm
support for custom types. The issue I found with this is that my type is generic and this does not currently seem to be supported bysea-orm
. When I run my code theDeriveEntityModel
macro panics (refer to the code linked below).I put together some code here which should help show the sort of syntax I am going for without all the complexity and macros of the
async-graphql-relay
codebase.Thanks, @billy1624 for creating PR #400 which is going to be the fix for this.
The text was updated successfully, but these errors were encountered: