aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb3
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
2 files 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 1c237eda33..a4194defc2 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,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
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 13f55319a7..8bbc47ab75 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -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