Hello all,
I''m getting stale-object-error from AR on objects that have
lock_version
defined in MS SQL Server 2000.
The problem is not repeatable as of yet, and is happening on something as
simple as the User table from LoginGenerator, to which I''ve added:
lock_version int default(0) not null
Has anyone experienced this problem?
Here''s some script/console output (this is actually from James
Adam''s
LoginEngine). Notice that nothing is different between the User.find calls.
>> user = User.find(:first, :conditions=>"login =
''admin''")
=> #<User:0x372ebb0
@attributes={"salt"=>"ad71f490168ce50858feb1ebec0ec208b316d130",
"delete_after"=>nil, "updated_at"=>
"2005/11/28 12:40:32", "lock_version"=>2,
"security_token"=>nil,
"role"=>nil, "lastname"=>nil,
"firstname"=>nil, "id"=>4
8, "deleted"=>0, "token_expiry"=>nil,
"verified"=>1, "password_orig"=>"tmp",
"logged_in_at"=>nil, "salted_password"=>"fd
57d7ba5818df53eb6fd2c53501d856c272a534",
"login"=>"admin",
"created_at"=>"2004/09/01 15:53:34",
"email"=>nil}>>> user.change_password(''testing'',
''testing'')
=> true>> user.save
ActiveRecord::StaleObjectError: Attempted to update a stale object
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/locking.rb:42:in
`update_without_callb
acks''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/callbacks.rb:274:in
`update_without_ti
mestamps''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/timestamp.rb:39:in
`update''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:1431:in
`create_or_update_with
out_callbacks''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/callbacks.rb:249:in
`create_or_update''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/base.rb:1231:in
`save_without_validati
on''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/validations.rb:687:in
`save_without_tr
ansactions''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:126:in
`save''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:126:in
`transaction''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:91:in
`transaction''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:118:in
`transaction''
from
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:126:in
`save''
from (irb):4
from :0>> user = User.find(:first, :conditions=>"login =
''admin''")
=> #<User:0x3a6ad48
@attributes={"salt"=>"ad71f490168ce50858feb1ebec0ec208b316d130",
"delete_after"=>nil, "updated_at"=>
"2005/11/28 12:40:32", "lock_version"=>2,
"security_token"=>nil,
"role"=>nil, "lastname"=>nil,
"firstname"=>nil, "id"=>4
8, "deleted"=>0, "token_expiry"=>nil,
"verified"=>1, "password_orig"=>"tmp",
"logged_in_at"=>nil, "salted_password"=>"fd
57d7ba5818df53eb6fd2c53501d856c272a534",
"login"=>"admin",
"created_at"=>"2004/09/01 15:53:34",
"email"=>nil}>>> user.change_password(''testing'',
''testing'')
=> true>> user.save
=> true
--
------------------------------
dried fruit and clams
------------------------------
Peter Fitzgibbons
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails