You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug in gorm or just missing from documentation for breaking changes between gorm v1 and v2. This problem didn't exist in gorm v1.
When adding where conditions with structs, the table named is fixed to clause.CurrentTable regardless of the struct type. For example:
I am migrating from gorm v1 to gorm v2 and I found this difference that I don't think is documented in Breaking changes
stmt:=DB.Session(&gorm.Session{DryRun: true}).
Select("*").
Joins("join users on users.id = pets.user_id").
Where(&User{Name: "user_name"}).Find(&pets).Statementexpect:="SELECT * FROM `pets` join users on users.id = pets.user_id WHERE `users`.`name` = ? AND `pets`.`deleted_at` IS NULL"got:="SELECT * FROM `pets` join users on users.id = pets.user_id WHERE `pets`.`name` = ? AND `pets`.`deleted_at` IS NULL"
The text was updated successfully, but these errors were encountered:
It seems like the issue was introduced in minor versions of v2 (not between v1 and v2, like I initially thought).
This issue was introduced in 3cd81ff. To me #3382 seems an invalid issue. The problem could have been solved by adding TableName method on RecordInfo, not by hardcoding all Where(Model{}) to the same table specified by Table().
I'm not sure if this is a bug in gorm or just missing from documentation for breaking changes between gorm v1 and v2. This problem didn't exist in gorm v1.
When adding where conditions with structs, the table named is fixed to
clause.CurrentTable
regardless of the struct type. For example:SQL:
go-gorm/playground#656
Description
I am migrating from gorm v1 to gorm v2 and I found this difference that I don't think is documented in Breaking changes
The text was updated successfully, but these errors were encountered: