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
Add a test case for unscoping default_scope
in associations
#29611
Merged
rafaelfranca
merged 1 commit into
rails:master
from
kamipo:add_test_case_for_unscoping_default_scope
Jun 28, 2017
Merged
Add a test case for unscoping default_scope
in associations
#29611
rafaelfranca
merged 1 commit into
rails:master
from
kamipo:add_test_case_for_unscoping_default_scope
Jun 28, 2017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unscoping `default_scope` in associations has already supported (rails#17360 for preloading, c9cf8b8 for eager loading). Fixes rails#20679. Closes rails#16531.
Thank you thank you thank you! ❤️ |
kamipo
added a commit
to kamipo/rails
that referenced
this pull request
Apr 15, 2020
rails#29589 changed merging scope order to allow to unscope default scopes on association scope (rails#29611), but that caused a regression rails#38811 that accidentally allow join constraint which is required. ``` % bin/test test/cases/associations/has_many_associations_test.rb -n test_unscopes_the_default_scope_of_associated_model_when_used_with_include Run options: -n test_unscopes_the_default_scope_of_associated_model_when_used_with_include --seed 32978 # Running: E Error: HasManyAssociationsTest#test_unscopes_the_default_scope_of_associated_model_when_used_with_include: NoMethodError: undefined method `children' for nil:NilClass ~/rails/activerecord/lib/active_record/associations/join_dependency/join_association.rb:39:in `block in join_constraints' ~/rails/activerecord/lib/active_record/associations/join_dependency/join_association.rb:30:in `reverse_each' ~/rails/activerecord/lib/active_record/associations/join_dependency/join_association.rb:30:in `with_index' ~/rails/activerecord/lib/active_record/associations/join_dependency/join_association.rb:30:in `join_constraints' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:171:in `make_constraints' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:196:in `block in walk' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:196:in `each' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:196:in `flat_map' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:196:in `walk' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:90:in `block in join_constraints' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:87:in `each' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:87:in `flat_map' ~/rails/activerecord/lib/active_record/associations/join_dependency.rb:87:in `join_constraints' ~/rails/activerecord/lib/active_record/relation/query_methods.rb:1226:in `build_join_query' ~/rails/activerecord/lib/active_record/relation/query_methods.rb:1211:in `build_joins' ~/rails/activerecord/lib/active_record/relation/query_methods.rb:1091:in `build_arel' ~/rails/activerecord/lib/active_record/relation/query_methods.rb:1063:in `arel' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:419:in `block in limited_ids_for' ~/rails/activerecord/lib/active_record/relation.rb:867:in `skip_query_cache_if_necessary' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:419:in `limited_ids_for' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:398:in `apply_join_dependency' ~/rails/activerecord/lib/active_record/relation.rb:839:in `block in exec_queries' ~/rails/activerecord/lib/active_record/relation.rb:867:in `skip_query_cache_if_necessary' ~/rails/activerecord/lib/active_record/relation.rb:834:in `exec_queries' ~/rails/activerecord/lib/active_record/relation.rb:639:in `load' ~/rails/activerecord/lib/active_record/relation.rb:250:in `records' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:508:in `find_take' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:98:in `take' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:458:in `find_one' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:442:in `find_with_ids' ~/rails/activerecord/lib/active_record/relation/finder_methods.rb:69:in `find' ~/rails/activerecord/test/cases/associations/has_many_associations_test.rb:2689:in `block in <class:HasManyAssociationsTest>' bin/test test/cases/associations/has_many_associations_test.rb:2683 ``` Required join constraint should not be allowed to unscoping. Fixes rails#38811.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unscoping
default_scope
in associations has already supported (#17360for preloading, c9cf8b8 for eager loading).
Fixes #20679.
Closes #16531.