提交 9c1c551f 编写于 作者: R Raimonds Simanovskis

Explicitly select * from has_and_belongs_to_many association tables, simplify exists? query

Previous version (after commit 3103296a) was generating wrong SQL for Oracle when calling exists? method on HABTM association.
上级 40afcade
......@@ -83,7 +83,8 @@ def finder_options
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 @@ def all(*args)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册