diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-05 09:47:13 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-05 09:47:13 -0800 |
commit | e468a62dc89d4d3c2a16a6d3e8fd78342a2732df (patch) | |
tree | 98271f86684e9bc3fbf65068fa542cbdfe1571fe /activerecord/lib/active_record | |
parent | 35a225535f38df551a1399b596622f3e3a0bbfbe (diff) | |
download | rails-e468a62dc89d4d3c2a16a6d3e8fd78342a2732df.tar.gz rails-e468a62dc89d4d3c2a16a6d3e8fd78342a2732df.tar.bz2 rails-e468a62dc89d4d3c2a16a6d3e8fd78342a2732df.zip |
use arel ast construction rather than generating strings
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index f3b1c9de3f..a8e1ea21c4 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -68,7 +68,13 @@ module ActiveRecord end def construct_joins - "INNER JOIN #{@owner.connection.quote_table_name @reflection.options[:join_table]} ON #{@reflection.quoted_table_name}.#{@reflection.klass.primary_key} = #{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.association_foreign_key}" + right = join_table + left = @reflection.klass.arel_table + + condition = left[@reflection.klass.primary_key].eq( + right[@reflection.association_foreign_key]) + + right.create_join(right, right.create_on(condition)) end def join_table |