8000 Bug: string id is always required convert to int64 · Issue #384 · ent/ent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Bug: string id is always required convert to int64 #384
Closed
@fitzix

Description

@fitzix

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0