Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What did this pull request do?
In MySQL, delete supports inner joins (but not left joins).
This PR does two things to make it possible for us to use
InnerJoin
to build a clause into our delete SQL statements.query.go
intojoin.go
to allow it to be re-used in delete (now) and possibly in update (in future work).DELETE
keyword.The problems with this PR:
InnerJoins
or aJoins
- so this will buildDELETE t FROM t LEFT JOIN r WHERE ...;
statements if it is passed a normal left join - when this is invalid SQL. The logic should be upgraded to silently discard the join, or emit an error that says"You cannot left join in a delete statement. Maybe you meant to inner join instead?"
.HandleJoins
function takes two callback arguments - to make it very faithful to what initially happened inquery.go
and ensure no regressions.I'm reluctant to solve those three problems until a contributor goes through the logic and verifies that the work done is meaningful. If that's the case, we can have a discussion about the organization of the code, and error handling / silent discarding of clause for left joins, and once the logic is finalized, I'll introduce tests for it.
User Case Description