diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-14 06:50:25 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-14 06:50:25 +0900 |
commit | e9c16536d462503abd37e0ce5c34032fc1e39fdb (patch) | |
tree | f80b87f436a9736fd0d215f73573c8dcef794478 /activerecord/lib/active_record/associations/alias_tracker.rb | |
parent | 0c743885baba1681ad43376f6444b52a306fdfd9 (diff) | |
download | rails-e9c16536d462503abd37e0ce5c34032fc1e39fdb.tar.gz rails-e9c16536d462503abd37e0ce5c34032fc1e39fdb.tar.bz2 rails-e9c16536d462503abd37e0ce5c34032fc1e39fdb.zip |
Don't pass garbage args to alias tracker
This is a complete fix to #30995.
Originally alias tracker will only track table aliases on
`Arel::Nodes::Join`, other args are ignored.
Since c5ab6e5, parent aliases hash will be passed then it caused the
regression #30995.
It is enough to pass list of `Arel::Nodes::Join` simply, not need to
pass garbage args which will be ignored.
Diffstat (limited to 'activerecord/lib/active_record/associations/alias_tracker.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/alias_tracker.rb | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb index 14881cfe17..4f3893588e 100644 --- a/activerecord/lib/active_record/associations/alias_tracker.rb +++ b/activerecord/lib/active_record/associations/alias_tracker.rb @@ -30,20 +30,12 @@ module ActiveRecord join.left.scan( /JOIN(?:\s+\w+)?\s+(?:\S+\s+)?(?:#{quoted_name}|#{name})\sON/i ).size - elsif join.respond_to? :left + elsif join.is_a?(Arel::Nodes::Join) join.left.name == name ? 1 : 0 elsif join.is_a?(Hash) join.fetch(name, 0) else - # this branch is reached by two tests: - # - # activerecord/test/cases/associations/cascaded_eager_loading_test.rb:37 - # with :posts - # - # activerecord/test/cases/associations/eager_test.rb:1133 - # with :comments - # - 0 + raise ArgumentError, "joins list should be initialized by list of Arel::Nodes::Join" end end |