forked from mirror/gorm
Include tag settings when clone a StructField
This commit is contained in:
parent
2392e2a33e
commit
84942c60b8
|
@ -11,6 +11,11 @@ type CalculateField struct {
|
|||
Name string
|
||||
Children []CalculateFieldChild
|
||||
Category CalculateFieldCategory
|
||||
EmbeddedField
|
||||
}
|
||||
|
||||
type EmbeddedField struct {
|
||||
EmbeddedName string `sql:"NOT NULL;DEFAULT:'hello'"`
|
||||
}
|
||||
|
||||
type CalculateFieldChild struct {
|
||||
|
@ -31,4 +36,10 @@ func TestCalculateField(t *testing.T) {
|
|||
if fields["children"].Relationship == nil || fields["category"].Relationship == nil {
|
||||
t.Errorf("Should calculate fields correctly for the first time")
|
||||
}
|
||||
|
||||
if field, ok := fields["embedded_name"]; !ok {
|
||||
t.Errorf("should find embedded field")
|
||||
} else if _, ok := field.TagSettings["NOT NULL"]; !ok {
|
||||
t.Errorf("should find embedded field's tag settings")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ func (structField *StructField) clone() *StructField {
|
|||
IsScanner: structField.IsScanner,
|
||||
HasDefaultValue: structField.HasDefaultValue,
|
||||
Tag: structField.Tag,
|
||||
TagSettings: structField.TagSettings,
|
||||
Struct: structField.Struct,
|
||||
IsForeignKey: structField.IsForeignKey,
|
||||
Relationship: structField.Relationship,
|
||||
|
|
Loading…
Reference in New Issue