diff --git a/dialect/entsql/annotation.go b/dialect/entsql/annotation.go index c153a310d..90b1136e6 100644 --- a/dialect/entsql/annotation.go +++ b/dialect/entsql/annotation.go @@ -57,4 +57,37 @@ func (Annotation) Name() string { return "EntSQL" } -var _ schema.Annotation = (*Annotation)(nil) +// Merge implements the schema.Merger interface. +func (a *Annotation) Merge(other schema.Annotation) { + var ant Annotation + switch other := other.(type) { + case Annotation: + ant = other + case *Annotation: + if other != nil { + ant = *other + } + default: + return + } + if t := ant.Table; t != "" { + a.Table = t + } + if c := ant.Charset; c != "" { + a.Charset = c + } + if c := ant.Collation; c != "" { + a.Collation = c + } + if o := ant.Options; o != "" { + a.Options = o + } + if s := ant.Size; s != 0 { + a.Size = s + } +} + +var ( + _ schema.Annotation = (*Annotation)(nil) + _ schema.Merger = (*Annotation)(nil) +)