From c683b81e5de958890d774c520ac38a089dc0c89e Mon Sep 17 00:00:00 2001 From: CoderAlim <152273373+CoderAlim@users.noreply.github.com> Date: Tue, 28 Nov 2023 04:56:26 -0600 Subject: [PATCH] fix error time (previes wrong time) when select multiple nullable time using type time.Time When the column type allows for optional datetime fields, if we set the field type as time.Time and there is a scenario where one record in the query result has this field while another does not, it may lead to the occurrence of dirty data where the field value of the second record is the same as the field value of the first record --- schema/field.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/schema/field.go b/schema/field.go index 657e0a4bd..69365a967 100644 --- a/schema/field.go +++ b/schema/field.go @@ -824,6 +824,8 @@ func (field *Field) setupValuerAndSetter() { case **time.Time: if data != nil && *data != nil { field.Set(ctx, value, *data) + }else{ + field.Set(ctx, value, nil) } case time.Time: field.ReflectValueOf(ctx, value).Set(reflect.ValueOf(v))