Merge remote branch 'rsim/habtm_select_fix'

* rsim/habtm_select_fix:
  Explicitly select * from has_and_belongs_to_many association tables, simplify exists? query
This commit is contained in:
Aaron Patterson 2011-01-04 15:08:28 -08:00
commit c08fccf980
2 changed files with 3 additions and 2 deletions

View File

@ -83,7 +83,8 @@ module ActiveRecord
super.merge(
:joins => construct_joins,
:readonly => ambiguous_select?(@reflection.options[:select]),
:select => @reflection.options[:select] || Arel.star
:select => @reflection.options[:select] ||
Arel.sql("#{@reflection.quoted_table_name}.*, #{@owner.connection.quote_table_name @reflection.options[:join_table]}.*")
)
end

View File

@ -171,7 +171,7 @@ module ActiveRecord
def exists?(id = nil)
id = id.id if ActiveRecord::Base === id
relation = select(table[primary_key]).limit(1)
relation = select("1").limit(1)
case id
when Array, Hash