diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-05-05 12:35:29 -0400 |
---|---|---|
committer | Ernie Miller <ernie@metautonomo.us> | 2011-05-05 12:35:29 -0400 |
commit | 8d270a2abbc1601777f4918bd1968c18f7864ae5 (patch) | |
tree | afe26d262bd63b3ecf62fad368143d1c5c3c9ec0 /activerecord/lib/active_record/associations | |
parent | ee898e5248d3876372c8303f500afe2baf6f298c (diff) | |
download | rails-8d270a2abbc1601777f4918bd1968c18f7864ae5.tar.gz rails-8d270a2abbc1601777f4918bd1968c18f7864ae5.tar.bz2 rails-8d270a2abbc1601777f4918bd1968c18f7864ae5.zip |
Add join conditions to JOIN clause, not WHERE
Diffstat (limited to 'activerecord/lib/active_record/associations')
-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 |