aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index d13bed95ce..3c9c9c4e84 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -91,7 +91,7 @@ module ActiveRecord
def first(limit = nil)
if limit
if order_values.empty? && primary_key
- order("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(limit).to_a
+ order(arel_table[primary_key].asc).limit(limit).to_a
else
limit(limit).to_a
end
@@ -117,7 +117,7 @@ module ActiveRecord
def last(limit = nil)
if limit
if order_values.empty? && primary_key
- order("#{quoted_table_name}.#{quoted_primary_key} DESC").limit(limit).reverse
+ order(arel_table[primary_key].desc).limit(limit).reverse
else
to_a.last(limit)
end
@@ -362,7 +362,7 @@ module ActiveRecord
else
@first ||=
if order_values.empty? && primary_key
- order("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(1).to_a.first
+ order(arel_table[primary_key].asc).limit(1).to_a.first
else
limit(1).to_a.first
end