entc/gen: derive the id-type from the schema (#823)

if it was not provided
This commit is contained in:
Ariel Mashraki
2020-10-06 16:29:09 +03:00
committed by GitHub
parent 3f3debbe97
commit 48362e79cd
3 changed files with 31 additions and 5 deletions

View File

@@ -160,11 +160,15 @@ type (
// NewType creates a new type and its fields from the given schema.
func NewType(c *Config, schema *load.Schema) (*Type, error) {
idType := c.IDType
if idType == nil {
idType = defaultIDType
}
typ := &Type{
Config: c,
ID: &Field{
Name: "id",
Type: c.IDType,
Type: idType,
StructTag: structTag("id", ""),
},
schema: schema,