Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with declaring composite key in ROM #110

Closed
bluekites opened this issue Dec 3, 2016 · 2 comments
Closed

Issue with declaring composite key in ROM #110

bluekites opened this issue Dec 3, 2016 · 2 comments
Milestone

Comments

@bluekites
Copy link

I was trying to follow the documentation to create a composite key for a relation.

The current setup is primary_key :job_id, :user_id

However, calling the primary_key only yields the job_id and does not return both values. I believe this is preventing me from updating and deleting by_pk

Two current workaround we used was to add an extra customized view :by_cpk which will handle the two primary keys or by declaring a new method in the specific relation with the composite key to handle the primary keys that we need it to.

1st)

view(:by_cpk, attributes[:base]) do |pk1, pk2|
    where(:job_opening_id => pk1, :user_id => pk2)
end

2nd)

def by_cpk(user_id, job_opening_id)
    where(user_id: user_id, job_opening_id: job_opening_id)
end
@solnic solnic added this to the 1.0.0 milestone Dec 3, 2016
@solnic
Copy link
Member

solnic commented Dec 3, 2016

Thanks for reporting this. CPKs are not fully supported yet so let's make it one of the goals for 1.0.0 :)

@solnic
Copy link
Member

solnic commented Jan 27, 2017

Sorry, didn't manage to make this work in 1.0.0. Setting it for 1.0.1

@solnic solnic modified the milestones: v1.0.1, 1.0.0 Jan 27, 2017
@solnic solnic closed this as completed in 74951d4 Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants