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

Many-to-Many scenario with no real FKs done via overridden view #238

Closed
wants to merge 2 commits into from

Conversation

solnic
Copy link
Member

@solnic solnic commented Aug 23, 2017

refs #236

@solnic solnic force-pushed the fix-multiple-m-t-m-assoc branch from 2373391 to 3d37e4d Compare August 23, 2017 11:52
@solnic solnic changed the title [wip] add a spec Many-to-Many scenario with no real FKs done via overridden view Aug 23, 2017

def for_eans(assoc, eans)
join(:contract_ean_stats, contract_id: contracts[:id]).
join(:ean_stats, ean_id: eans.pluck(:id)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solnic if Sequel doesn't do anything I don't know about, you did a cartesian join here and, usually, you don't need such a join :)

this should be similar to

join(:contract_ean_stats, contract_id: contracts[:id]).
  join(:ean_stats, contract_id: contracts[:id]).
  select_append(ean_stats[:ean_id]).
  where(ean_id: eans.pluck(:id))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flash-gordon yeah I had a feeling something ain't right. I'd actually appreciate if you could pull in this branch locally and see if this works. IIRC I tried what you wrote here but it didn't work (query was invalid)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solnic agh, right, I was wrong. Fixed it here 91d4d75

@solnic solnic closed this Nov 17, 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

Successfully merging this pull request may close these issues.

2 participants