mirror of https://github.com/go-gorm/gorm.git
Compatible with tag notNull
This commit is contained in:
parent
7faf1ca80f
commit
3d846957cd
|
@ -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) {
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue