Partially revert the change made in https://github.com/go-gorm/gorm/pull/6311 that appears to have broken this for us and at least one other person.

This commit is contained in:
henryjcee 2024-10-08 17:55:24 +01:00
parent 05110579be
commit 72e580c566
No known key found for this signature in database
GPG Key ID: 80F585CB00A434A8
2 changed files with 5 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/jinzhu/now" "github.com/jinzhu/now"
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
"gorm.io/gorm/utils" "gorm.io/gorm/utils"
) )
@ -922,7 +923,7 @@ func (field *Field) setupValuerAndSetter() {
if !reflectV.IsValid() { if !reflectV.IsValid() {
field.ReflectValueOf(ctx, value).Set(reflect.New(field.FieldType).Elem()) field.ReflectValueOf(ctx, value).Set(reflect.New(field.FieldType).Elem())
} else if reflectV.Kind() == reflect.Ptr && reflectV.IsNil() { } else if reflectV.Kind() == reflect.Ptr && reflectV.IsNil() {
return field.ReflectValueOf(ctx, value).Set(reflect.New(field.FieldType).Elem())
} else if reflectV.Type().AssignableTo(field.FieldType) { } else if reflectV.Type().AssignableTo(field.FieldType) {
field.ReflectValueOf(ctx, value).Set(reflectV) field.ReflectValueOf(ctx, value).Set(reflectV)
} else if reflectV.Kind() == reflect.Ptr { } else if reflectV.Kind() == reflect.Ptr {

View File

@ -1,6 +1,8 @@
module gorm.io/gorm/tests module gorm.io/gorm/tests
go 1.18 go 1.21
toolchain go1.23.2
require ( require (
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0