Can lock_version be ignored?

I have a need to update a record but without changing the
lock_version – or to at least .save without triggering a stale error
if the lock_version has changed.

Is either possible? I’ve tried the API and some blogs, so far no
hints…

– gw

On 22 Jun 2008, at 12:12, Greg W. wrote:

I have a need to update a record but without changing the
lock_version – or to at least .save without triggering a stale error
if the lock_version has changed.

Is either possible? I’ve tried the API and some blogs, so far no
hints…

def without_locking
old_value, ActiveRecord::Base.lock_optimistically =
ActiveRecord::Base.lock_optimistically, false
yield
ensure
ActiveRecord::Base.lock_optimistically = old_value
end

You could whack that into activerecord if you used it often enough.
That said, if I wanted to ignore optimisic locking then I probably
wouldn’t be using it in the first place.

Fred