This project is archived and is in readonly mode.

#6058 open
Valentine Bichkovsky

update_all ignores conditions, when :orders and :limit options are supplied

Reported by Valentine Bichkovsky | November 24th, 2010 @ 06:03 PM

Rails version: 3.0.2 and 3.0.3 (no such bug in Rails 3.0.1)
Ruby 1.8.7
Adapter: postgres

In code:

Reservation.update_all("status = 'ready'", 
  ["date = ? and crossing_point_id = ? and position > ?", 
   Time.zone.today, crossing_point.id, last_crossed],
  :order => :position, :limit => params[:count])

In log file:

AREL (15.0ms) UPDATE "reservations" SET status = 'ready' WHERE "reservations"."id" IN (SELECT "reservations"."id" FROM "reservations" ORDER BY position LIMIT 4)

After removing :order and :limit options

In code:

Reservation.update_all("status = 'ready'", 
  ["date = ? and crossing_point_id = ? and position > ?", 
   Time.zone.today, crossing_point.id, last_crossed])

In log file:

AREL (29.7ms)  UPDATE "reservations" SET status = 'ready' WHERE (date = '2010-11-24' and crossing_point_id = 2 and position > 182)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages