fix: support empty IN clause across all dialects#6887
Merged
imnotjames merged 2 commits intotypeorm:masterfrom Oct 15, 2020
Merged
fix: support empty IN clause across all dialects#6887imnotjames merged 2 commits intotypeorm:masterfrom
IN clause across all dialects#6887imnotjames merged 2 commits intotypeorm:masterfrom
Conversation
we were supporting an empty `IN` clause for MySQL and Oracle and this updates the handling to be for all other dialects as well by making the "empty" clause be `0=1` fixes typeorm#2195
Contributor
Author
|
The test commit had CI ran against it to show the failures - the results can be found here |
Contributor
Author
|
From a performance standpoint, all query optimizers that I've checked prevent the query from even doing any work (EG, this will turn the entire query into a no-op, so no table scan happens). The negation turns the expression itself into a no-op and it has no effect on the query. I checked this against the following databases via an EXPLAIN or comparable tool:
|
|
Cool, thanks for working on this |
zaro
pushed a commit
to zaro/typeorm
that referenced
this pull request
Jan 12, 2021
we were supporting an empty `IN` clause for MySQL and Oracle and this updates the handling to be for all other dialects as well by making the "empty" clause be `0=1` Closes typeorm#4865 fixes typeorm#2195
This was referenced Jan 29, 2021
This was referenced Oct 20, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
we were supporting an empty
INclause for MySQL and Oracleand this updates the handling to be for all other dialects as well
by making the "empty" clause be
0=1This follows the lead of a number of other projects in a similar space:
1=01!=11=01!=1I've also chosen to use
1=0in the empty case because it's the most likely technique which allows the various query optimizers to do their magic. :)Closes #4865
fixes #2195