
Defining a property called 'model' causes a stack overflow
Reported by Ashley Moran | April 25th, 2009 @ 01:36 PM | in 1.0.0
The following code:
require 'rubygems'
require 'datamapper'
DataMapper.setup(:default, :adapter => 'in_memory')
class RecursiveFail
include DataMapper::Resource
property :id, Serial
property :model, String
end
r = RecursiveFail.new(:model => "test")
puts r.model
produces the following stack trace:
/opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get': stack level too deep (SystemStackError)
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:106:in `attribute_get'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:451:in `model'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:568:in `properties'
... 4368 levels...
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:615:in `assert_valid_model'
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:609:in `initialize'
from recursive_property_name.rb:13:in `new'
from recursive_property_name.rb:13
Comments and changes to this ticket
-
Dan Kubb (dkubb) April 29th, 2009 @ 12:49 AM
- Assigned user set to Dan Kubb (dkubb)
- State changed from unconfirmed to accepted
I'm not sure how to deal with that. "model" is a heavily used method inside dm-core internals. Also every method in DataMapper::Resource could potentially collide with a method or property defined in the Model.
Perhaps it's time for us to either start prefixing the methods with underscores, or set up something to warn when you use a "reserved" method.
I'll take this ticket on and think about the best approach.
-
Dan Kubb (dkubb) June 16th, 2009 @ 03:19 AM
- Milestone set to 0.10.1
-
Dan Kubb (dkubb) October 4th, 2009 @ 09:33 PM
- Milestone changed from 0.10.1 to 0.10.2
[project:id#20609 not-tagged:"0.10.0" not-tagged:"0.10.1" milestone:id#51895 bulk edit command]
-
Dan Kubb (dkubb) February 1st, 2010 @ 04:33 PM
- Milestone changed from 0.10.2 to 1.0.0
-
-
-
Dan Kubb (dkubb) February 2nd, 2010 @ 02:47 AM
- State changed from accepted to confirmed
-
Dan Kubb (dkubb) February 3rd, 2010 @ 03:32 AM
- State changed from confirmed to resolved
- Milestone set to 1.0.0
Edge dm-core has fixes that prevent this problem. Marking this as resolved.
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 »