#1506 ✓resolved

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
    property :aid, Integer, :key => true
    # other stuff

    belongs_to :b, :model => 'B', :child_key => [ :bid ]


class B
    include DataMapper::Resource

    property :bid, Integer, :key => true
    # other stuff

    belongs_to :c, :model => 'C', :child_key => [ :cid ]


class C
    include DataMapper::Resource

    property :cid, Integer, :key => true
    # other stuff

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)

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

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 »

People watching this ticket

Referenced by