aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-09-01 12:04:29 -0400
committerSantiago Pastorino <santiago@wyeworks.com>2010-09-05 08:13:42 -0300
commit91fec0d24d50d3b3e90c48b2501ca913544781cc (patch)
treef3dd8ff6c1f9b1ca6f3029a827297904ce165e22 /activerecord/lib/active_record
parentf9c21ce6580601109a6c4ac55c63bdea031f3203 (diff)
downloadrails-91fec0d24d50d3b3e90c48b2501ca913544781cc.tar.gz
rails-91fec0d24d50d3b3e90c48b2501ca913544781cc.tar.bz2
rails-91fec0d24d50d3b3e90c48b2501ca913544781cc.zip
order should always be concatenated.
order that is declared first has highest priority in all cases. Here are some examples. Car.order('name desc').find(:first, :order => 'id').name Car.named_scope_with_order.named_scope_with_another_order Car.order('id DESC').scoping do Car.find(:first, :order => 'id asc') end No special treatment to with_scope or scoping. Also note that if default_scope declares an order then the order declared in default_scope has the highest priority unless with_exclusive_scope is used. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 4b2c647a26..e3f1496b9a 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -99,9 +99,8 @@ module ActiveRecord
relation = relation.readonly(options[:readonly]) if options.key? :readonly
- # Give precedence to newly-applied orders and groups to play nicely with with_scope
[:group, :order].each do |finder|
- relation.send("#{finder}_values=", Array.wrap(options[finder]) + relation.send("#{finder}_values")) if options.has_key?(finder)
+ relation.send("#{finder}_values=", relation.send("#{finder}_values") + Array.wrap(options[finder])) if options.has_key?(finder)
end
relation = relation.where(options[:conditions]) if options.has_key?(:conditions)