diff --git a/schema/field.go b/schema/field.go index de4d9f3d0..243819960 100644 --- a/schema/field.go +++ b/schema/field.go @@ -896,7 +896,7 @@ func (field *Field) setupValuerAndSetter() { if !reflectV.IsValid() { field.ReflectValueOf(ctx, value).Set(reflect.New(field.FieldType).Elem()) } else if reflectV.Kind() == reflect.Ptr && reflectV.IsNil() { - if field.FieldType.Elem().Kind() == reflect.Array { + if field.FieldType.Elem().Kind() == reflect.Array && field.OwnerSchema == nil { field.ReflectValueOf(ctx, value).Set(reflectV) } } else if reflectV.Type().AssignableTo(field.FieldType) { diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 3351ed8e0..2d7973f6f 100644 --- a/tests/embedded_struct_test.go +++ b/tests/embedded_struct_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/google/uuid" "gorm.io/gorm" . "gorm.io/gorm/utils/tests" ) @@ -114,6 +115,7 @@ func TestEmbeddedPointerTypeStruct(t *testing.T) { ContentPtr *Content Birthday time.Time BirthdayPtr *time.Time + AuthorUUID *uuid.UUID } type HNPost struct {