Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Eliminate extra queries when using Optimistic Locking with Partial Updates

#426

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.

Reported by Daniel Morrison · June 15th, 2008 @ 09:41 PM

State: resolved
Milestone: 2.1.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 2.1.1
    • State changed from new to open
    • Assigned user set to Jeremy Kemper

    June 16th, 2008 @ 12:27 PM

  2. Repository
    Repository
    • State changed from open to resolved

    (from [44b890740003d27a4d80a07df33efd57476d37e4]) Partial updates don't update lock_version if nothing changed. [#426 state:resolved]

    http://github.com/rails/rails/co...

    June 23rd, 2008 @ 04:37 AM

  3. Repository
    Repository

    (from [3610997ba32128921115bedb89c322a7bcbe161a]) Partial updates don't update lock_version if nothing changed. [#426 state:resolved]

    http://github.com/rails/rails/co...

    June 23rd, 2008 @ 04:37 AM