From 35a225535f38df551a1399b596622f3e3a0bbfbe Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 5 Jan 2011 09:23:25 -0800 Subject: use arel to construct AST rather than generate strings --- .../associations/has_and_belongs_to_many_association.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 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 a4194defc2..f3b1c9de3f 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 @@ -83,8 +83,9 @@ module ActiveRecord super.merge( :joins => construct_joins, :readonly => ambiguous_select?(@reflection.options[:select]), - :select => @reflection.options[:select] || - Arel.sql("#{@reflection.quoted_table_name}.*, #{@owner.connection.quote_table_name @reflection.options[:join_table]}.*") + :select => @reflection.options[:select] || [ + @reflection.klass.arel_table[Arel.star], + join_table[Arel.star]] ) end -- cgit v1.2.3