-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unscoping default_scope in eager_loaded associations #16531
Support unscoping default_scope in eager_loaded associations #16531
Conversation
@rafaelfranca or @jonleighton is there anything else I should add? |
fd4fab3
to
db08e83
Compare
For eager_loaded joins move the default scope to the front of the scope chain to be merged first. For preloading check values for unscope and add to the scope being built unscope_values. On preload, no need to change merge sequence given default scope is merged first.
db08e83
to
5884821
Compare
What happens if |
unscoped { includes } is broken in rails 4+ so we try to avoid this bug by disabling eager loading -> triggering less includes maybe coming fix: rails/rails#16531
unscoped { includes } is broken in rails 4+ so we try to avoid this bug by disabling eager loading -> triggering less includes maybe coming fix: rails/rails#16531
unscoped { includes } is broken in rails 4+ so we try to avoid this bug by disabling eager loading -> triggering less includes maybe coming fix: rails/rails#16531
unscoped { includes } is broken in rails 4+ so we try to avoid this bug by disabling eager loading -> triggering less includes maybe coming fix: rails/rails#16531
unscoped { includes } is broken in rails 4+ so we try to avoid this bug by disabling eager loading -> triggering less includes maybe coming fix: rails/rails#16531
Any chance of this being backported to Rails 4.2 as well? |
Is this fixed in rails 5? |
This will fix #20679 for joins/eager_load and also covers preload/includes(without references). While we can unscope default_scope in joins/eager_load by #18109, somehow the counterpart for preload/includes is rejected in #25187. So this PR would be the only way to unscope default_scipe in preload/includes. @cwjenkins Could you rebase this against master? |
Unscoping `default_scope` in associations has already supported (rails#17360 for preloading, c9cf8b8 for eager loading). Fixes rails#20679. Closes rails#16531.
For eager_loaded joins move the default scope to the front of the scope chain to be merged first.
For preloading check values for unscope and add to the scope being built unscope_values.
On preload, no need to change merge sequence given default scope is merged first.