Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

composite keys in a rails project #12

Open
Ragmaanir opened this Issue · 2 comments

2 participants

@Ragmaanir

Im not sure if this is caused by dm-rails.
The code is here:
https://gist.github.com/1011318

You can execute the _setup.sh (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: https://gist.github.com/1010908

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

@solnic
Owner

Is this still a problem?

@Ragmaanir

It seems so. I adjusted the gist to rails 3.1.1 and dm 1.2.0: https://gist.github.com/1011318

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: https://gist.github.com/1011318#file_spec_models_friendship_spec.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.