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.
Description
Fixing issue #4978 - fixing an issue with using the keyword 'in' as part of an SQL query.
The fix for this has to make some changes to the SQL query itself, switching to a
where id in ($1, $2, $3)
syntax, this utilises some of the work that was put in place around string concatenation to find instances that need swapped. Currently this will look for the keywordin
(any casing) before a binding, if found it will switch it to use this syntax. This is also dependent on the inserted value being a string of comma separated values that were to be used as in parameters, however this should always be true as that is the format that would have been used if the bindings were directly interpolated into the SQL query itself.I've tested this with multiple in queries as well, as well as using in for a single string value (no comma separation). If there are no commas it will just generate a syntax like
in ($1)
where the string value is the only one used.I've also added a
SQL_MAX_ROWS
env variable, so that self hosters can set the max number of rows returned by SQL queries (greater than 5000) if they desire to export large SQL tables.