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
=== RUN TestGORM/Distinct_preloads
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:45
[0.283ms] [rows:1] SELECT * FROM `companies` WHERE `companies`.`id` = 1
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:45
[0.276ms] [rows:1] SELECT * FROM `users` WHERE `users`.`id` = 1
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:45
[1.571ms] [rows:1] SELECT * FROM `users` WHERE `users`.`id` = 2 AND `users`.`deleted_at` IS NULL
=== RUN TestGORM/Preload_all
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.149ms] [rows:0] SELECT * FROM `accounts` WHERE `accounts`.`user_id` = 2 AND `accounts`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.240ms] [rows:0] SELECT * FROM `companies` WHERE `companies`.`id` = 1 AND `companies`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.127ms] [rows:0] SELECT * FROM `user_friends` WHERE `user_friends`.`user_id` = 2
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.120ms] [rows:0] SELECT * FROM `user_speaks` WHERE `user_speaks`.`user_id` = 2
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.119ms] [rows:0] SELECT * FROM `users` WHERE `users`.`id` = 1 AND `users`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.119ms] [rows:0] SELECT * FROM `pets` WHERE `pets`.`user_id` = 2 AND `pets`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.121ms] [rows:0] SELECT * FROM `users` WHERE `users`.`manager_id` = 2 AND `users`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[0.134ms] [rows:0] SELECT * FROM `toys` WHERE `owner_type` = "users" AND `toys`.`owner_id` = 2 AND `toys`.`deleted_at` IS NULL
2021/11/04 12:55:47 /Users/abas/vmware/gorm-playground/main_test.go:62
[2.554ms] [rows:1] SELECT * FROM `users` WHERE `users`.`id` = 2 AND `users`.`deleted_at` IS NULL
main_test.go:66: Wrong company name
main_test.go:69: Wrong manager
The Unscoped is basically ignored for the "Preload All" case, with deleted_at IS NULL` being added to queries.
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#397
Description
I want to use
Unscoped
with a "preload all" to load all associations, but it is not working as expected.The following fails to load associations which have been soft-deleted:
While the following (load specific associations by name) succeeds:
Notice the differences in SQL queries:
The
Unscoped
is basically ignored for the "Preload All" case, withdeleted_at
IS NULL` being added to queries.The text was updated successfully, but these errors were encountered: