#909 ✓resolved
dan (at angryamoeba)

Destroyed objects raise errors when attempting to access unloaded attributes

Reported by dan (at angryamoeba) | June 17th, 2009 @ 10:23 AM

This issue occurs when using property types that are by default lazy-loaded. Attempting to access lazy attributes once an object has been destroyed raises a frozen object error.

Desired behaviour: Either the lazy attributes should be loaded before the object is destroyed (not always practical with large entities such as BLOB fields) or the exception should be handled by DM's exception classes so that the implementing application can handle the error.

To reproduce:

class MyModel
  include DataMapper::Resource
  property :id, Serial
  property :foo, String
  property :long, Text
end

win = MyModel.gen
win.long #=> "dsfargeg"
win.destroy
win.long #=> "dsfargeg"

fail = MyModel.gen
fail.destroy
fail.long 

can't modify frozen object
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.0/lib/dm-core/property.rb:630:in `instance_variable_set'
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.0/lib/dm-core/property.rb:630:in `set!'
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.0/lib/dm-core/property.rb:611:in `set'
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.0/lib/dm-core/property.rb:541:in `get'
/Library/Ruby/Gems/1.8/gems/dm-core-0.10.0/lib/dm-core/resource.rb:174:in `attribute_get'

Comments and changes to this ticket

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages