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

PLIN-2085: Fixing multitenancy keys on joins to be part of the ON clause #68

Merged
merged 2 commits into from
May 23, 2019

Conversation

bnewtonius
Copy link

Doing a left join with multitenancy keys in the WHERE clause causes empty results if there is not a referenced record.

FROM tablea AS t0
LEFT JOIN tableb AS t1 ON t0.parent_id = t1.id
WHERE t1.organization_id = 'some_org_id'

Moving it to the ON clause fixes this so that we still get the left table's records even if there is no right table record:

FROM tablea AS t0
LEFT JOIN tableb AS t1 ON (t0.parent_id = t1.id AND t1.organization_id = 'some_org_id'

This change pulls out the multitenancy key and treats it differently. It still adds it to the WHERE clause for the left most table, but then adds it to the ON clause of the JOIN for all of the other tables.

@bnewtonius bnewtonius merged commit c74a05a into master May 23, 2019
@bnewtonius bnewtonius deleted the feature-PLIN-2085 branch May 23, 2019 16:17
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