dialect/entsql: implement merge for annotations

This commit is contained in:
Ariel Mashraki
2020-12-13 18:13:32 +02:00
committed by Ariel Mashraki
parent 088af734f0
commit ad01a0aadb

View File

@@ -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)
)