aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorMarcelo Silveira <marcelo@mhfs.com.br>2012-04-27 20:19:11 -0300
committerMarcelo Silveira <marcelo@mhfs.com.br>2012-05-02 21:25:41 -0300
commit878db1f4ef842a7c6c406aefb4dd2e629b5f47af (patch)
tree4347c59bc41d508b9a3eaeaea69488ce4e5ad332 /activerecord/lib/active_record/relation
parent2bf65caf565c5923684953557594fc287c80c6ca (diff)
downloadrails-878db1f4ef842a7c6c406aefb4dd2e629b5f47af.tar.gz
rails-878db1f4ef842a7c6c406aefb4dd2e629b5f47af.tar.bz2
rails-878db1f4ef842a7c6c406aefb4dd2e629b5f47af.zip
Use arel nodes instead of raw sql
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