diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-05 13:23:15 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-05 13:23:15 -0700 |
commit | 030e1d06ca36e1ed235f8e34ac9bfb6906b12dce (patch) | |
tree | c52f53c5bcab6151728e0167602297c870f4617d /activerecord/lib | |
parent | f098c80947dee1b420cea4ca647d1ceb3e59eaea (diff) | |
parent | 9b7cd75db340b6d0c6f2ec342ae4d7a201e46e84 (diff) | |
download | rails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.tar.gz rails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.tar.bz2 rails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.zip |
Merge pull request #399 from ernie/join_conditions_on_join
Add association join conditions to JOIN clause, not WHERE
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 0a666598ed..c32753782f 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -91,12 +91,12 @@ module ActiveRecord constraint = build_constraint(reflection, table, key, foreign_table, foreign_key) - relation.from(join(table, constraint)) - unless conditions[i].empty? - relation.where(sanitize(conditions[i], table)) + constraint = constraint.and(sanitize(conditions[i], table)) end + relation.from(join(table, constraint)) + # The current table in this iteration becomes the foreign table in the next foreign_table = table end |