entc/gen: add support for default annotation to PKs as well (#1492)

This commit is contained in:
Vojtěch Káně
2021-04-22 13:16:53 +02:00
committed by GitHub
parent de150626fc
commit 43ef74b8a8
2 changed files with 7 additions and 3 deletions

View File

@@ -1198,6 +1198,11 @@ func (f Field) PK() *schema.Column {
c.Size = *f.def.Size
}
}
// Override the default-value defined in the
// schema if it was provided by an annotation.
if ant := f.EntSQL(); ant != nil && ant.Default != "" {
c.Default = strconv.Quote(ant.Default)
}
if f.def != nil {
c.SchemaType = f.def.SchemaType
}