On 1/4/06, Phillip Hershkowitz <philhersh@hotmail.com>
wrote:> Hi,
>
> Is there a way to tell Rails that the magic field name for optimistic
> database locking is not lock_version? I have a legacy database where the
> optimistic locking field is named "version".
>
> Thanks,
> Phil
>
I just made a patch against the stable version of Rails that lets you
set the name of the locking column on your model classes.
Example:
class LegacyThing < ActiveRecord::Base
set_locking_column :version
end
If you don''t specify a column name, it defaults to lock_version. So
far I''ve only tested it against Oracle, but it basically
doesn''t
change the SQL code, so you should be fine with other DBMSes.
The patch is against revision 3381, the latest stable version, but it
should apply against anything, since the locking.rb file hasn''t been
changed in 6 months.
Hopefully this will help you out. :)
--Wilson.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: activerecord_set_locking_column.diff
Type: application/octet-stream
Size: 2139 bytes
Desc: not available
Url :
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/03f621a1/activerecord_set_locking_column.obj