aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-05-05 13:23:15 -0700
committerJon Leighton <j@jonathanleighton.com>2011-05-05 13:23:15 -0700
commit030e1d06ca36e1ed235f8e34ac9bfb6906b12dce (patch)
treec52f53c5bcab6151728e0167602297c870f4617d /activerecord/lib
parentf098c80947dee1b420cea4ca647d1ceb3e59eaea (diff)
parent9b7cd75db340b6d0c6f2ec342ae4d7a201e46e84 (diff)
downloadrails-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.rb6
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