
Can only chain up to first time changing default repository.
Reported by timmy_tofu | April 21st, 2011 @ 04:46 PM | in 1.1.1
Assume I have setup properly a :default repository and another called :alt_db.
class A
include DataMapper::Resource
def self.default_repository_name
:alt_db
end
property :aid, Integer, :key => true
# other stuff
belongs_to :b, :model => 'B', :child_key => [ :bid ]
end
class B
include DataMapper::Resource
property :bid, Integer, :key => true
# other stuff
belongs_to :c, :model => 'C', :child_key => [ :cid ]
end
class C
include DataMapper::Resource
property :cid, Integer, :key => true
# other stuff
end
Trying to run this generates the following error:
dm-core/model/property.rb:73:in `new': wrong number of arguments (4 for 3) (ArgumentError)
Digging into the DM source from the stack trace:
DataMapper.repository(other_repository_name) do
properties << klass.new(self, name, options, type)
end
That's where the error is raised. Indeed, in this case klass is a DataMapper Integer property, and it's initialize method only accepts three options (model, name, and an options hash).
This whole block is only executed because I'm using more than one repository.
So, I can only chain as far as B in this case. If, on the other hand, A and B both had the same default_repository (either :default or :alt_db) and C were another by default, then I can chain as far as C. But, attempting to chain further to D will fail, regardless of which repository D uses as it's default.
Comments and changes to this ticket
-
Piotr Solnica (solnic) April 22nd, 2011 @ 05:10 AM
- State changed from new to confirmed
- Milestone set to 1.1.1
- Assigned user set to Piotr Solnica (solnic)
- Milestone order changed from 196352 to 0
-
Piotr Solnica (solnic) April 22nd, 2011 @ 07:34 AM
- State changed from confirmed to resolved
(from [5dd1bc9592afebb5e24826639a46c30e8bedf5d8]) Fixed property creation for repositories other than the default
[#1506 state:resolved] https://github.com/datamapper/dm-core/commit/5dd1bc9592afebb5e24826...
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
Referenced by
-
1506 Can only chain up to first time changing default repository. [#1506 state:resolved] https://github.com/datamapper/dm-...