This project is archived and is in readonly mode.

#426 ✓resolved
Daniel Morrison

Eliminate extra queries when using Optimistic Locking with Partial Updates

Reported by Daniel Morrison | June 15th, 2008 @ 09:41 PM | in 2.1.1

If you use optimistic locking with partial updates, you get extra queries where they aren't needed.

Example (save a person without updates):

Person.first
Person.save!

Generates:

  Person Update with optimistic locking (0.000400)    UPDATE `people`
 SET `lock_version` = 14
 WHERE id = 339
 AND `lock_version` = 13

This patch duplicates the functionality of ActiveRecord::Base#update, where the update isn't run if there are no fields in the update.

Therefore, when you use locking with partial updates, you won't have extra queries floating around.

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>

Attachments

Pages