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
fix: don't treat \
as escape in standard strings, support E-strings, support vars after ->>
operator
#14700
Conversation
Do we need a similar PR for v6? |
Yep! I'll need to backport this :) |
Adding an extra fix |
\
as escape in standard strings, support E-strings\
as escape in standard strings, support E-strings, support vars after ->>
operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Few small questions
|| ( | ||
dialect.supports.escapeStringConstants | ||
// is this a E-prefixed string, such as `E'abc'` ? | ||
&& sqlString[i - 1] === 'E' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this also check for lowercase 'e'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should! Thanks for double checking :)
🎉 This PR is included in version 7.0.0-alpha.15 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hey. Didn't have the time so far. Looking at this pr I got the impression that it was rather tricky but given that it's mostly a matter of replicating things, sure why not :) |
We also support support vars after ->> operator now. Backport of #14700
…support vars after ->> operator, treat lowercase e as valid e-string prefix (#15139) * fix: don't treat \ as escape in standard strings, support E-strings We also support support vars after ->> operator now. Backport of #14700 * fix(postgres): treat lowercase e as valid e-string prefix * fix: nullish coalescence * fix: cleanup * fix: spaces * fix: postgres tests * fix: add third param to trigger right behavior * fix: tests * fix: formatting * fix: remove unused code * meta: more formatting * meta: more formatting * fix: merge test cases
Pull Request Checklist
yarn test
oryarn test-DIALECT
pass with this change (including linting)?Description Of Change
Closes #14693
This PR fixes
injectReplacements
andmapBindParameters
to support:\
cannot be used to escape'
\
-based escaping, even ifstandardConformingStrings
is true->
&->>
operatorsAs a result, these two methods will now throw if the SQL includes unterminated string literals.
It was painful to test that one dialect threw (because it did not support
\
escaping), and another did not, so I introduced a newexpectPerDialect
utility based onexpectsql
Here is such an example:
I also expanded
expectsql
to accept a combination of dialects separated by a space as the key, to reduce duplication (mainly for mysql/mariadb). e.g. the following is now possible: