
Collection attempts to modify frozen Resource.
Reported by Shane Hanna | May 29th, 2009 @ 02:31 AM
Calling methods (.size, .destroy etc.) on a Collection of frozen (no primary key so readonly) objects causes a runtime error because it can't modify the fozen object(s).
Stacktrace from the error:
RuntimeError: can't modify frozen object
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1097:in `relate_resource'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1118:in `block in relate_resources'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1118:in `each'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:1118:in `relate_resources'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:499:in `concat'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:989:in `lazy_load'
/opt/local/lib/ruby/gems/1.9.1/gems/extlib-0.9.13/lib/extlib/lazy_array.rb:459:in `size'
Stacktrace from an overloaded Model#freeze:
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/model.rb:583:in `block in load'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/model.rb:526:in `map'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/model.rb:526:in `load'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/repository.rb:145:in `read'
/opt/local/lib/ruby/gems/1.9.1/gems/dm-core-0.10.0/lib/dm-core/collection.rb:982:in `lazy_load'
/opt/local/lib/ruby/gems/1.9.1/gems/extlib-0.9.13/lib/extlib/lazy_array.rb:459:in `size'
Cheers,
Shane.
Comments and changes to this ticket
-
Dan Kubb (dkubb) May 29th, 2009 @ 11:23 PM
- State changed from unconfirmed to resolved
(from [d40580b091c26c7bf27e599aa7133b38331d2f1a]) Only related or orphan a Resource if it is not frozen
[#870 state:resolved] http://github.com/datamapper/dm-core/commit/d40580b091c26c7bf27e599...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Tags
Referenced by
-
870 Collection attempts to modify frozen Resource. [#870 state:resolved] http://github.com/datamapper/dm-co...