diff --git a/schema/field.go b/schema/field.go index db516c33..e7f5b708 100644 --- a/schema/field.go +++ b/schema/field.go @@ -170,6 +170,8 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { if val, ok := field.TagSettings["NOT NULL"]; ok && utils.CheckTruth(val) { field.NotNull = true + } else if val, ok := field.TagSettings["NOTNULL"]; ok && utils.CheckTruth(val) { + field.NotNull = true } if val, ok := field.TagSettings["UNIQUE"]; ok && utils.CheckTruth(val) { diff --git a/tests/default_value_test.go b/tests/default_value_test.go index aa4a511a..14a0a977 100644 --- a/tests/default_value_test.go +++ b/tests/default_value_test.go @@ -10,9 +10,9 @@ func TestDefaultValue(t *testing.T) { type Harumph struct { gorm.Model Email string `gorm:"not null;index:,unique"` - Name string `gorm:"not null;default:foo"` + Name string `gorm:"notNull;default:foo"` Name2 string `gorm:"size:233;not null;default:'foo'"` - Name3 string `gorm:"size:233;not null;default:''"` + Name3 string `gorm:"size:233;notNull;default:''"` Age int `gorm:"default:18"` Enabled bool `gorm:"default:true"` }