mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
schema/mixin: add support for mixed-in annotations
This commit is contained in:
committed by
Ariel Mashraki
parent
85c4999472
commit
c8a6527612
@@ -158,12 +158,13 @@ func MarshalSchema(schema ent.Interface) (b []byte, err error) {
|
||||
Name: indirect(reflect.TypeOf(schema)).Name(),
|
||||
Annotations: make(map[string]interface{}),
|
||||
}
|
||||
for _, at := range schema.Annotations() {
|
||||
s.Annotations[at.Name()] = at
|
||||
}
|
||||
if err := s.loadMixin(schema); err != nil {
|
||||
return nil, fmt.Errorf("schema %q: %v", s.Name, err)
|
||||
}
|
||||
// Schema annotations override mixed-in annotations.
|
||||
for _, at := range schema.Annotations() {
|
||||
s.Annotations[at.Name()] = at
|
||||
}
|
||||
if err := s.loadFields(schema); err != nil {
|
||||
return nil, fmt.Errorf("schema %q: %v", s.Name, err)
|
||||
}
|
||||
@@ -263,6 +264,9 @@ func (s *Schema) loadMixin(schema ent.Interface) error {
|
||||
MixinIndex: i,
|
||||
})
|
||||
}
|
||||
for _, at := range mx.Annotations() {
|
||||
s.Annotations[at.Name()] = at
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user