-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Fix eager loading association using default_scope for finder methods. #19586
Fix eager loading association using default_scope for finder methods. #19586
Conversation
978b802
to
03609fd
Compare
@rafaelfranca Sorry I don't know to whom to address this PR currently. So I pinged you. Actually yesterday I sent this PR. But today morning, I saw that Travis CI got failed. I checked that and my PR got failed mostly for jruby and rbx related builds. Today I rebased with master and did force push to my branch. But now Travis doesn't show any status. Let me know if I missed something. |
No problem, Is this PR fixing any issue? |
@rafaelfranca I just checked that is there any similar issues to this issue. But didn't get any. Actually I found this issue while testing this file |
@@ -142,6 +142,7 @@ def find(*ids) # :nodoc: | |||
return super if block_given? || | |||
primary_key.nil? || | |||
scope_attributes? || | |||
respond_to?(:default_scope) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not we only return if it is a eager loading?
@rafaelfranca I'm not getting your point. Could you elaborate more on it?. Also one more thing, I have added something like this,
Let me know your thoughts |
@rafaelfranca Also it is not just about eager loading. Actually problem is, if we define
Suppose posts table has columns like If we try to search a post like,
Then here 'default_scope' doesn't work. It doesn't not load |
Right, now I get the problem. Yeah, I think we should move the |
03609fd
to
100d33d
Compare
- Eager loading was not working for the default_scope (class method) for 'find' & 'find_by' methods. - Fixed these by adding a new check 'respond_to?(:default_scope)'.
100d33d
to
4596e16
Compare
@rafaelfranca I have update code and moved |
…-methods Fix eager loading association using default_scope for finder methods.
for 'find' & 'find_by' methods.