Skip to content

fix: accept replacements in ARRAY[] & followed by ;#14518

Merged
ephys merged 2 commits into
v6from
ephys/fix-v6-replacements
May 18, 2022
Merged

fix: accept replacements in ARRAY[] & followed by ;#14518
ephys merged 2 commits into
v6from
ephys/fix-v6-replacements

Conversation

@ephys
Copy link
Copy Markdown
Member

@ephys ephys commented May 18, 2022

Pull Request Checklist

Please make sure to review and check all of these items:

  • Have you added new tests to prevent regressions?
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

Closes #14517
Other bug report: #14472 (comment)

This PR fixes the replacement parser to replace them in the following two queries:

-- replacements were not transformed in arrays
SELECT * FROM users WHERE id = ARRAY[:id]::int[];
SELECT * FROM users WHERE id = ARRAY[?]::int[];
-- replacements were not transformed if followed by ';'
SELECT * FROM users WHERE id = :id;
SELECT * FROM users WHERE id = ?;

@ephys ephys changed the title fix: accept repl in ARRAY[] & followed by ; fix: accept replacements in ARRAY[] & followed by ; May 18, 2022
Copy link
Copy Markdown
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

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

Are we only doing this for v6?

@ephys
Copy link
Copy Markdown
Member Author

ephys commented May 18, 2022

No, I'll port it to v7 once the v6 version is approved and merged :)

@ephys ephys merged commit e37c572 into v6 May 18, 2022
@ephys ephys deleted the ephys/fix-v6-replacements branch May 18, 2022 10:26
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.19.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sdepold
Copy link
Copy Markdown
Member

sdepold commented May 18, 2022

Good job :)

Comment thread src/utils/sql.ts
// users need to add a space before the bind parameter (except after '(', ',', and '=')
if (previousChar !== undefined && !/[\s(,=]/.test(previousChar)) {
// users need to add a space before the bind parameter (except after '(', ',', and '=', '[' (for arrays))
if (previousChar !== undefined && !/[\s(,=[]/.test(previousChar)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and shall be after '=' and before '['

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh yeah, good catch

aliatsis pushed a commit to creditiq/sequelize that referenced this pull request Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants