composite keys in a rails project #12

Ragmaanir opened this Issue Jun 6, 2011 · 3 comments

3 participants


Im not sure if this is caused by dm-rails.
The code is here:

You can execute the (copy & paste to terminal) which should setup a rails 3 project with a Gemfile, rspec, the models and one spec. The spec should fail (at least when i execute it it fails with "expected: nil got: nil").

It seems like during the DataMapper.auto_migrate! the columns in the Database for Friendship.request are not created. In a standalone test with the same models though it works and Friendship has one :request_sender_id and :request_receiver_id property. The standalone-spec is here:

Am i doing something wrong or is this a dm-rails/dm-migration/whatever bug?

DataMapper member

Is this still a problem?


It seems so. I adjusted the gist to rails 3.1.1 and dm 1.2.0:

The Friendship class has a

belongs_to :request, 'FriendshipRequest'

but the SQL output from auto_migrate is:

CREATE TABLE "friendships" ("user_id" INTEGER NOT NULL, "friend_id" INTEGER NOT NULL, PRIMARY KEY("user_id", "friend_id"))

and the error of the spec is:

1) Friendship
 Failure/Error: fs.request.should_not be_nil
   expected: not nil
        got: nil
 # ./spec/models/friendship_spec.rb:16:in `block (2 levels) in <top (required)>'

in the spec:

DataMapper member

This could be either a dm-migrations or sqlite issue.

If this is still a problem, can you update the gist again. It's no longer runnable.

I'll reopen if this is an issue still.

@tpitale tpitale closed this Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment