Skip to content

Commit

Permalink
fix error time (previes wrong time) when select multiple nullable tim…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
CoderAlim authored Nov 28, 2023
1 parent 3207ad6 commit c683b81
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions schema/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 828 in schema/field.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 Error return value is not checked (errcheck) Raw Output: schema/field.go:828:16: Error return value is not checked (errcheck) field.Set(ctx, value, nil) ^
}
case time.Time:
field.ReflectValueOf(ctx, value).Set(reflect.ValueOf(v))
Expand Down

0 comments on commit c683b81

Please sign in to comment.