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.

Optimistic Locking and Double Quoting of Strings

#6578

Follow up to: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets..., as I wasn't able to comment on that ticket (updates kept disappearing).

Reported by: Alexander Gorkunov

Content:

In: activerecord/lib/active_record/locking/optimistic.rb

line 91:

relation.table[self.class.primary_key].eq(quoted_id).and(

quoted_id is superfluous because it quoted in arel engine.
So in compiled SQL we get : '''id''' instead of 'id'
This problem has already fixed in destroy statement (see line 117)

--

Included is a patch to resolve this issue. The delete method uses ID, not quoted ID, as ARel will quote it.

Follow this same convention.

Reported by Christopher Meiklejohn · March 15th, 2011 @ 02:26 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Christopher Meiklejohn
    Christopher Meiklejohn

    Just wondering if someone had a chance to take a look at the included patch?

    March 16th, 2011 @ 06:09 PM

  2. bingbing
  3. jgpawletko
    jgpawletko

    I just confirmed the same bug as Christopher Meiklejohn.
    (Thank you Christopher for the fix.)

    As of this writing the problem does not appear to be fixed in the current 3.0-stable release of rails.
    https://github.com/rails/rails/blob/3-0-stable/activerecord/lib/act...
    line 91.

    (rdb:2) pp quoted_id "'64536156-E2F3-4659-BB55-483FA43BF672'" (rdb:2) pp relation.where(relation.table[self.class.primary_key].eq(quoted_id)) [] (rdb:2) pp relation.where(relation.table[self.class.primary_key].eq('64536156-E2F3-4659-BB55-483FA43BF672')) [#]

    May 2nd, 2011 @ 03:53 AM