mirror of https://github.com/rails/rails
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:
commit
c08fccf980
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue