mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/entsql: implement merge for annotations
This commit is contained in:
committed by
Ariel Mashraki
parent
088af734f0
commit
ad01a0aadb
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user