From debc5f179ecbc2ba8b5ee7c210a8deac1490902b Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 12:19:55 +0530 Subject: [PATCH 1/6] fix: Assigning nil value to *uuid.UUID field in Updates This PR adds handling for the assignment of a nil value to a *uuid.UUID field (resolved as a reflect.Ptr to a reflect.Array), to ensure that the model object reflects the correct value after Updates() has completed. This PR also adds few supporting test cases for Updates() with a map and uuid.UUID column. --- schema/field.go | 4 +++- tests/connpool_test.go | 6 +++--- tests/embedded_struct_test.go | 2 ++ tests/go.mod | 1 + tests/sql_builder_test.go | 6 +++--- tests/update_test.go | 33 +++++++++++++++++++++++++++++++++ utils/tests/models.go | 2 ++ 7 files changed, 47 insertions(+), 7 deletions(-) diff --git a/schema/field.go b/schema/field.go index d1a633ce..e03fe053 100644 --- a/schema/field.go +++ b/schema/field.go @@ -896,7 +896,9 @@ 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() { - return + if field.FieldType.Elem().Kind() == reflect.Array && field.OwnerSchema == nil { + field.ReflectValueOf(ctx, value).Set(reflectV) + } } else if reflectV.Type().AssignableTo(field.FieldType) { field.ReflectValueOf(ctx, value).Set(reflectV) } else if reflectV.Kind() == reflect.Ptr { diff --git a/tests/connpool_test.go b/tests/connpool_test.go index 21a2bad0..3e878da6 100644 --- a/tests/connpool_test.go +++ b/tests/connpool_test.go @@ -101,12 +101,12 @@ func TestConnPoolWrapper(t *testing.T) { db: nativeDB, expect: []string{ "SELECT VERSION()", - "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`) VALUES (?,?,?,?,?,?,?,?,?)", + "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`,`user_uuid`) VALUES (?,?,?,?,?,?,?,?,?,?)", "SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?", - "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`) VALUES (?,?,?,?,?,?,?,?,?)", + "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`,`user_uuid`) VALUES (?,?,?,?,?,?,?,?,?,?)", "SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?", "SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?", - "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`) VALUES (?,?,?,?,?,?,?,?,?)", + "INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`,`user_uuid`) VALUES (?,?,?,?,?,?,?,?,?,?)", "SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?", "SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?", }, diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 3351ed8e..2d7973f6 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 { diff --git a/tests/go.mod b/tests/go.mod index 30143433..1cfce16e 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -7,6 +7,7 @@ require ( github.com/jinzhu/now v1.1.5 github.com/lib/pq v1.10.9 github.com/stretchr/testify v1.9.0 + gorm.io/datatypes v1.2.2 gorm.io/driver/mysql v1.5.7 gorm.io/driver/postgres v1.5.10 gorm.io/driver/sqlite v1.5.6 diff --git a/tests/sql_builder_test.go b/tests/sql_builder_test.go index 0c204db4..0325bf82 100644 --- a/tests/sql_builder_test.go +++ b/tests/sql_builder_test.go @@ -158,7 +158,7 @@ func TestDryRun(t *testing.T) { dryRunDB := DB.Session(&gorm.Session{DryRun: true}) stmt := dryRunDB.Create(&user).Statement - if stmt.SQL.String() == "" || len(stmt.Vars) != 9 { + if stmt.SQL.String() == "" || len(stmt.Vars) != 10 { t.Errorf("Failed to generate sql, got %v", stmt.SQL.String()) } @@ -403,7 +403,7 @@ func TestToSQL(t *testing.T) { sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB { return tx.Model(&User{}).Create(user) }) - assertEqualSQL(t, `INSERT INTO "users" ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active") VALUES ('2021-10-18 00:00:00','2021-10-18 00:00:00',NULL,'foo',20,NULL,NULL,NULL,false) RETURNING "id"`, sql) + assertEqualSQL(t, `INSERT INTO "users" ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active","user_uuid") VALUES ('2021-10-18 00:00:00','2021-10-18 00:00:00',NULL,'foo',20,NULL,NULL,NULL,false,NULL) RETURNING "id"`, sql) // save user = &User{Name: "foo", Age: 20} @@ -412,7 +412,7 @@ func TestToSQL(t *testing.T) { sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB { return tx.Model(&User{}).Save(user) }) - assertEqualSQL(t, `INSERT INTO "users" ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active") VALUES ('2021-10-18 00:00:00','2021-10-18 00:00:00',NULL,'foo',20,NULL,NULL,NULL,false) RETURNING "id"`, sql) + assertEqualSQL(t, `INSERT INTO "users" ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active","user_uuid") VALUES ('2021-10-18 00:00:00','2021-10-18 00:00:00',NULL,'foo',20,NULL,NULL,NULL,false,NULL) RETURNING "id"`, sql) // updates user = &User{Name: "bar", Age: 22} diff --git a/tests/update_test.go b/tests/update_test.go index 9eb9dbfc..285e9602 100644 --- a/tests/update_test.go +++ b/tests/update_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "gorm.io/datatypes" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/utils" @@ -183,6 +184,38 @@ func TestUpdates(t *testing.T) { user3.Age += 100 AssertObjEqual(t, user4, user3, "UpdatedAt", "Age") + + // Updates() with map and datatypes.UUID - Case 1 - Update with UUID value + uuidVal := datatypes.NewUUIDv4() + tx := DB.Model(&user4) + uuidErr := tx.Updates(map[string]interface{}{"user_uuid": uuidVal}).Error + if uuidErr != nil { + t.Errorf("No error should occur while updating with UUID value, but got %v", uuidErr) + } + // Expecting the model object (user4) to reflect the UUID value assignment. + AssertEqual(t, user4.UserUUID, uuidVal) + + // Updates() with map and datatypes.UUID - Case 2 - Update with UUID nil pointer + var nilUUIDPtr *datatypes.UUID = nil + uuidErr = tx.Updates(map[string]interface{}{"user_uuid": nilUUIDPtr}).Error + if uuidErr != nil { + t.Errorf("No error should occur while updating with nil UUID pointer, but got %v", uuidErr) + } + // Expecting the model object (user4) to reflect the UUID nil pointer assignment. + AssertEqual(t, user4.UserUUID, nilUUIDPtr) + + // Updates() with map and datatypes.UUID - Case 3 - Update with a non-nil UUID pointer + uuidVal2 := datatypes.NewUUIDv1() + if uuidErr != nil { + t.Errorf("No error should occur while generating UUID, but got %v", uuidErr) + } + var nonNilUUIDPtr *datatypes.UUID = &uuidVal2 + uuidErr = tx.Updates(map[string]interface{}{"user_uuid": nonNilUUIDPtr}).Error + if uuidErr != nil { + t.Errorf("No error should occur while updating with non-nil UUID pointer, but got %v", uuidErr) + } + // Expecting the model object (user4) to reflect the non-nil UUID pointer assignment. + AssertEqual(t, user4.UserUUID, nonNilUUIDPtr) } func TestUpdateColumn(t *testing.T) { diff --git a/utils/tests/models.go b/utils/tests/models.go index f9f4f50e..060467c2 100644 --- a/utils/tests/models.go +++ b/utils/tests/models.go @@ -4,6 +4,7 @@ import ( "database/sql" "time" + "gorm.io/datatypes" "gorm.io/gorm" ) @@ -30,6 +31,7 @@ type User struct { Languages []Language `gorm:"many2many:UserSpeak;"` Friends []*User `gorm:"many2many:user_friends;"` Active bool + UserUUID *datatypes.UUID } type Account struct { From 4f6b1e9018408e55d07dd5afdbf45d0c25f42334 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 13:26:43 +0530 Subject: [PATCH 2/6] Keep bare minimum changes in go modules --- go.mod | 10 +++++++++- go.sum | 14 ++++++++++++++ tests/go.mod | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 3060fc8f..4bf67fa8 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,13 @@ go 1.18 require ( github.com/jinzhu/inflection v1.0.0 github.com/jinzhu/now v1.1.5 - golang.org/x/text v0.20.0 + golang.org/x/text v0.23.0 +) + +require ( + filippo.io/edwards25519 v1.1.0 // indirect + github.com/go-sql-driver/mysql v1.9.1 // indirect + github.com/google/uuid v1.6.0 // indirect + gorm.io/datatypes v1.2.5 // indirect + gorm.io/driver/mysql v1.5.7 // indirect ) diff --git a/go.sum b/go.sum index 9af11572..b10f5b18 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,20 @@ +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI= +github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gorm.io/datatypes v1.2.5 h1:9UogU3jkydFVW1bIVVeoYsTpLRgwDVW3rHfJG6/Ek9I= +gorm.io/datatypes v1.2.5/go.mod h1:I5FUdlKpLb5PMqeMQhm30CQ6jXP8Rj89xkTeCSAaAD4= +gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= +gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= +gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= diff --git a/tests/go.mod b/tests/go.mod index 1cfce16e..5dd60c69 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -7,7 +7,7 @@ require ( github.com/jinzhu/now v1.1.5 github.com/lib/pq v1.10.9 github.com/stretchr/testify v1.9.0 - gorm.io/datatypes v1.2.2 + gorm.io/datatypes v1.2.5 gorm.io/driver/mysql v1.5.7 gorm.io/driver/postgres v1.5.10 gorm.io/driver/sqlite v1.5.6 From cb6778015eec6a952198e61c16a43feee5c9b2a4 Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 13:32:28 +0530 Subject: [PATCH 3/6] Add tidy before running tests --- tests/tests_all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tests_all.sh b/tests/tests_all.sh index b221a7d8..f8b473ab 100755 --- a/tests/tests_all.sh +++ b/tests/tests_all.sh @@ -40,6 +40,8 @@ for dialect in "${dialects[@]}" ; do then echo "testing ${dialect}..." + go mod tidy + if [ "$GORM_VERBOSE" = "" ] then GORM_DIALECT=${dialect} go test -race -count=1 ./... From d2107c38ecaf127fbbf16a9e9a4537f57339a70c Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:45:29 +0530 Subject: [PATCH 4/6] Resolve all go module dependency errors --- go.mod | 6 ++++-- go.sum | 28 ++++++++++++++++++++++++++-- tests/go.mod | 21 +++++++++++---------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 4bf67fa8..0cd697a8 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,19 @@ module gorm.io/gorm -go 1.18 +go 1.23.0 + +toolchain go1.23.6 require ( github.com/jinzhu/inflection v1.0.0 github.com/jinzhu/now v1.1.5 golang.org/x/text v0.23.0 + gorm.io/datatypes v1.2.5 ) require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/go-sql-driver/mysql v1.9.1 // indirect github.com/google/uuid v1.6.0 // indirect - gorm.io/datatypes v1.2.5 // indirect gorm.io/driver/mysql v1.5.7 // indirect ) diff --git a/go.sum b/go.sum index b10f5b18..73b0671f 100644 --- a/go.sum +++ b/go.sum @@ -3,18 +3,42 @@ filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4 github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.9.1 h1:FrjNGn/BsJQjVRuSa8CBrM5BWA9BWoXXat3KrtSb/iI= github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= +github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= +github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA= +github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= +github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA= +github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gorm.io/datatypes v1.2.5 h1:9UogU3jkydFVW1bIVVeoYsTpLRgwDVW3rHfJG6/Ek9I= gorm.io/datatypes v1.2.5/go.mod h1:I5FUdlKpLb5PMqeMQhm30CQ6jXP8Rj89xkTeCSAaAD4= gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= +gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U= +gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A= +gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU= +gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= +gorm.io/driver/sqlserver v1.5.4 h1:xA+Y1KDNspv79q43bPyjDMUgHoYHLhXYmdFcYPobg8g= +gorm.io/driver/sqlserver v1.5.4/go.mod h1:+frZ/qYmuna11zHPlh5oc2O6ZA/lS88Keb0XSH1Zh/g= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= diff --git a/tests/go.mod b/tests/go.mod index 5dd60c69..5b8807cb 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -1,16 +1,18 @@ module gorm.io/gorm/tests -go 1.18 +go 1.23.0 + +toolchain go1.23.6 require ( github.com/google/uuid v1.6.0 github.com/jinzhu/now v1.1.5 github.com/lib/pq v1.10.9 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 gorm.io/datatypes v1.2.5 gorm.io/driver/mysql v1.5.7 - gorm.io/driver/postgres v1.5.10 - gorm.io/driver/sqlite v1.5.6 + gorm.io/driver/postgres v1.5.11 + gorm.io/driver/sqlite v1.5.7 gorm.io/driver/sqlserver v1.5.4 gorm.io/gorm v1.25.12 ) @@ -18,20 +20,19 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-sql-driver/mysql v1.8.1 // indirect + github.com/go-sql-driver/mysql v1.9.1 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.7.1 // indirect + github.com/jackc/pgx/v5 v5.7.4 // indirect github.com/jinzhu/inflection v1.0.0 // indirect - github.com/kr/text v0.2.0 // indirect github.com/mattn/go-sqlite3 v1.14.24 // indirect - github.com/microsoft/go-mssqldb v1.7.2 // indirect + github.com/microsoft/go-mssqldb v1.8.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - golang.org/x/crypto v0.29.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/text v0.23.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) From d1488896f7fa9486bf332554a8e0ab4a60eb520b Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:46:34 +0530 Subject: [PATCH 5/6] Remove tidy before go test --- tests/tests_all.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/tests_all.sh b/tests/tests_all.sh index f8b473ab..b221a7d8 100755 --- a/tests/tests_all.sh +++ b/tests/tests_all.sh @@ -40,8 +40,6 @@ for dialect in "${dialects[@]}" ; do then echo "testing ${dialect}..." - go mod tidy - if [ "$GORM_VERBOSE" = "" ] then GORM_DIALECT=${dialect} go test -race -count=1 ./... From 31ae7feae2ae051b1b4c9694f07dc2ca1699c00f Mon Sep 17 00:00:00 2001 From: Omkar P <45419097+omkar-foss@users.noreply.github.com> Date: Tue, 1 Apr 2025 14:55:25 +0530 Subject: [PATCH 6/6] Remove unused field AuthorUUID --- tests/embedded_struct_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 2d7973f6..3351ed8e 100644 --- a/tests/embedded_struct_test.go +++ b/tests/embedded_struct_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/google/uuid" "gorm.io/gorm" . "gorm.io/gorm/utils/tests" ) @@ -115,7 +114,6 @@ func TestEmbeddedPointerTypeStruct(t *testing.T) { ContentPtr *Content Birthday time.Time BirthdayPtr *time.Time - AuthorUUID *uuid.UUID } type HNPost struct {