Skip to content

Commit c33da49

Browse files
committed
default time null
1 parent 7aa2d38 commit c33da49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

orm/reflect.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,19 @@ func getStructFieldWithDefaultTime(obj any) (map[int]any, error) {
226226
defaultVar := tableStructType.Field(i).Tag.Get("default")
227227
name := tableStructType.Field(i).Tag.Get("json")
228228
ormName := tableStructType.Field(i).Tag.Get("orm")
229-
ormName = strings.Split(ormName, ",")[0]
229+
ormNames := strings.Split(ormName, ",")
230+
ormName = ormNames[0]
230231
if ormName != "" {
231232
name = ormName
232233
}
234+
if defaultVar == "" {
235+
for _, v := range ormNames {
236+
if strings.ToLower(v) == "null" {
237+
defaultVar = "null"
238+
break
239+
}
240+
}
241+
}
233242

234243
if _, ok := v.Interface().(time.Time); ok {
235244
lowerDefault := strings.ToLower(defaultVar)

0 commit comments

Comments
 (0)