
Property and PropertySet models with many to many association
Reported by matera.ttp | May 30th, 2009 @ 01:45 PM | in 0.10.2
[dm_test.rb]
require 'rubygems'
require 'dm-core'
for table
properties
properties
class Property include DataMapper::Resource property :id, Integer, :serial => true property :name, String
has n, :property_sets, :through => Resource end
for table property_sets
class PropertySet include DataMapper::Resource property :id, Integer, :serial => true property :name, String
has n, :properties, :through => Resource end
test code
DataMapper.setup(:default, { :host => 'localhost', :adapter => 'mysql', :database => 'test', :username => 'test', :password => '123' })
prop_set = PropertySet.new
[errors] $>ruby dm_test.rb
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property.rb:398:in
get': stack level too deep (SystemStackError)
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `get'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/model.rb:467:in `map'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:55:in `each'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:55:in `each'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `map'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `get'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/relationship_chain.rb:20:in `get_children'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/one_to_many.rb:251:in `children'
... 2278 levels...
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:617:in `assert_valid_model'
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/resource.rb:609:in `initialize'
from dm_test.rb:32:in `new'
from dm_test.rb:32
Comments and changes to this ticket
-
matera.ttp May 30th, 2009 @ 01:57 PM
require 'rubygems' require 'dm-core' class Option include DataMapper::Resource property :id, Integer, :serial => true property :name, String has n, :option_sets, :through => Resource end # for table property_sets class OptionSet include DataMapper::Resource property :id, Integer, :serial => true property :name, String has n, :options, :through => Resource end # test code DataMapper.setup(:default, { :host => 'localhost', :adapter => 'mysql', :database => 'test', :username => 'test', :password => '123' }) opt_set = OptionSet.new
This works fine.
But it shoud be possible to create models Property and PropertySet (tablesproperties
andproperty_sets
) -
matera.ttp May 31st, 2009 @ 02:03 AM
Summary: name of Model should not depend on internal implementation of DM
-
Dan Kubb (dkubb) May 31st, 2009 @ 12:42 PM
- State changed from unconfirmed to accepted
- Assigned user set to Dan Kubb (dkubb)
matera, you bring up a very valid point. I can confirm this is still an issue with dm-core/next, and have attached a script to demonstrate the issue. I would like to have it so model names can be named the same as ones we using internally within DataMapper without any errors (minus the DataMapper:: namespace prefix of course)
Do you have any suggestions for how to resolve this?
-
Dan Kubb (dkubb) June 16th, 2009 @ 03:16 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) November 10th, 2009 @ 02:38 AM
- State changed from accepted to not-applicable
For now I am going to mark this as invalid, or "won't fix".
There will always be classes that are reserved within DM, and regardless of what we change the names to there will always be naming collisions.
If you have a solution, please add it to this ticket, but for now I am going to close this.
-
matera.ttp November 10th, 2009 @ 10:31 AM
I tried to fix it by adding dm namespace to class names but this does not help. So I fix it by renaming my models.
-
Dan Kubb (dkubb) November 10th, 2009 @ 01:34 PM
@matera.tp: yeah I tried the same thing, but I couldn't get it to work. I'm think the issue might be more related to Ruby than DataMapper. However, if you do come up with a solution at some point please let me know.
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 »