diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-24 15:58:47 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-24 15:59:02 -0700 |
commit | 0fbf829b1e147c6c0f6c9d5e447bad0e9216b7b1 (patch) | |
tree | eebc48abb94b94768c08da72ad0adc2f60a6661a /activerecord | |
parent | 34d79fad85b0388270300a91430211ddc82cb183 (diff) | |
download | rails-0fbf829b1e147c6c0f6c9d5e447bad0e9216b7b1.tar.gz rails-0fbf829b1e147c6c0f6c9d5e447bad0e9216b7b1.tar.bz2 rails-0fbf829b1e147c6c0f6c9d5e447bad0e9216b7b1.zip |
stop the recursive insanity
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 9a882ba01a..dd73972416 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -166,14 +166,19 @@ module ActiveRecord if conditions || options.present? where(conditions).apply_finder_options(options.slice(:limit, :order)).update_all(updates) else + limit = nil + order = [] # Apply limit and order only if they're both present if @limit_value.present? == @order_values.present? - stmt = arel.compile_update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates))) - stmt.key = @klass.arel_table[@klass.primary_key] - @klass.connection.update stmt.to_sql - else - except(:limit, :order).update_all(updates) + limit = arel.limit + order = arel.orders end + + stmt = arel.compile_update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates))) + stmt.take limit + stmt.order(*order) + stmt.key = @klass.arel_table[@klass.primary_key] + @klass.connection.update stmt.to_sql end end |