mirror of https://github.com/go-gorm/gorm.git
Merge branch 'miya-masa-master'
This commit is contained in:
commit
2bb1b7c83e
|
@ -95,10 +95,15 @@ func (s *mysql) DataTypeOf(field *StructField) string {
|
||||||
}
|
}
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
if _, ok := dataValue.Interface().(time.Time); ok {
|
if _, ok := dataValue.Interface().(time.Time); ok {
|
||||||
|
precision := ""
|
||||||
|
if p, ok := field.TagSettings["PRECISION"]; ok {
|
||||||
|
precision = fmt.Sprintf("(%s)", p)
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := field.TagSettings["NOT NULL"]; ok {
|
if _, ok := field.TagSettings["NOT NULL"]; ok {
|
||||||
sqlType = "timestamp"
|
sqlType = fmt.Sprintf("timestamp%v", precision)
|
||||||
} else {
|
} else {
|
||||||
sqlType = "timestamp NULL"
|
sqlType = fmt.Sprintf("timestamp%v NULL", precision)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue