Thanks to visit codestin.com
Credit goes to github.com

Skip to content

field.ID() on join table doesn't work with custom ID  #2741

@amrnt

Description

@amrnt

Taking the example below, if the IDs were custom ids ie xid, and using field.ID("user_id", "role_id") will yield into the following error

type RoleUser struct {
	ent.Schema
}

func (RoleUser) Annotations() []schema.Annotation {
	return []schema.Annotation{
		field.ID("user_id", "role_id"),
	}
}
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

2022/07/11 12:55:42 running ent codegen: execute template "create": template: create.tmpl:208:5: executing "create" at <xtemplate $tmpl .>: error calling xtemplate: template: create.tmpl:239:6: executing "dialect/sql/create_bulk" at <xtemplate $tmpl $>: error calling xtemplate: template: upsert.tmpl:338:12: executing "helper/upsertbulk" at <$.ID.UserDefined>: nil pointer evaluating *gen.Field.UserDefined
exit status 1
main.go:3: running "go": exit status 1

Expected Behavior 🤔

generator not to return an error

Your Environment 🌎

Tech Version
Go 1.18
Ent master
Database Postgres
Driver pgx

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