Closed
Description
I confirmed that the problem of string id in migration #372 has been resolved, but when running the query All
scan, the string edge field is still required to be converted to int64
sql: Scan error on column index 2, name "user_card": converting driver.Value type string ("WKE81uvM88lJD_9W") to a int64: invalid syntax
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("id").MaxLen(16),
}
}
// Edges of the user.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("card", Card.Type).Unique(),
}
}
// Fields of the User.
func (Card) Fields() []ent.Field {
return nil
}
// Edges of the Card.
func (Card) Edges() []ent.Edge {
return []ent.Edge{
edge.From("owner", User.Type).
Ref("card").
Unique().
// We add the "Required" method to the builder
// to make this edge required on entity creation.
// i.e. Card cannot be created without its owner.
Required(),
}
}
client.User.Query().WithCard().All(context.Background())
Metadata
Metadata
Assignees
Labels
No labels