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
Using gorm.io/[email protected], gorm.io/[email protected], updated_at not touched in generated query when build via property obtained from Query in transaction of ReadDB() / WriteDB():
// expected behaviorquery.WriteDB().Transaction(func(tx*q.Query) error {
user:=tx.User// UPDATE `users` SET `name`=?,`updated_at`=? WHERE `users`.`name` = ? AND `users`.`deleted_at` IS NULLuser.WithContext(ctx).Where(user.Name.Eq(name)).UpdateSimple(user.Name.Value("test2"))
returnnil
})
// actual behaviorquery.WriteDB().Transaction(func(tx*q.Query) error {
user:=tx.User// UPDATE `users` SET `name`=? WHERE `users`.`name` = ? AND `users`.`deleted_at` IS NULLuser.WithContext(ctx).Where(user.Name.Eq(name)).UpdateSimple(user.Name.Value("test2"))
returnnil
})
When using without ReadDB() / WriteDB(), gorm generates expected SQL:
query.Transaction(func(tx*q.Query) error {
user:=tx.User// UPDATE `users` SET `name`=?,`updated_at`=? WHERE `users`.`name` = ? AND `users`.`deleted_at` IS NULLuser.WithContext(ctx).Where(user.Name.Eq(name)).UpdateSimple(user.Name.Value("test2"))
returnnil
})
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#785
Description
Using gorm.io/[email protected], gorm.io/[email protected],
updated_at
not touched in generated query when build via property obtained fromQuery
in transaction ofReadDB()
/WriteDB()
:When using without
ReadDB()
/WriteDB()
, gorm generates expected SQL:The text was updated successfully, but these errors were encountered: