Include tag settings when clone a StructField

This commit is contained in:
Jinzhu 2016-01-08 09:02:01 +08:00
parent 2392e2a33e
commit 84942c60b8
2 changed files with 12 additions and 0 deletions

View File

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

View File

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