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

NEW Add abstraction for sql RIGHT JOIN #10954

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

GuySartorelli
Copy link
Member

Currently adding a RIGHT JOIN to a query, especially to a DataQuery, is quite difficult.
Right joins are really powerful in conjunction with Common Table Expressions (aka WITH clauses), so now is a good time to add this abstraction.

Issue

/**
* Add a JOIN criteria
*/
private function addJoin($table, $type, $onPredicate, $tableAlias = null, $order = 20, $parameters = []): static
Copy link
Member Author

@GuySartorelli GuySartorelli Sep 21, 2023

Choose a reason for hiding this comment

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

This method wasn't strictly necessary, but it seems appropriate to reduce code duplication by moving the repeated code into this new method.
I can see a use case for this being public, but that's not the purpose of this PR. We can always do that as a separate future enhancement down the road.

public function testInnerJoin()
public function testJoinSQL()
Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't actually testing inner join - it was just testing the SQL output for both inner and left join. So I've just renamed it to match what it's actually testing, and added right join to it since it already had both existing join types in there.

@emteknetnz emteknetnz merged commit bbc0295 into silverstripe:5 Sep 24, 2023
15 checks passed
@emteknetnz emteknetnz deleted the pulls/5/right-join branch September 24, 2023 23:32
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