You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a raw query, the parser can run into a situation when it skips a part of a query, which supposed to be replaced by values from REPLACEMENTS array.
Lets assume that a user trying to implement a seed like below:
Reproducible Example
module.exports={up: (q)=>q.sequelize.transaction(async(transaction)=>{awaitq.sequelize.query("CREATE USER IF NOT EXISTS ?@? IDENTIFIED BY ?",{raw: true,replacements: ["test","localhost","abc123"],
transaction
});awaitq.sequelize.query("FLUSH PRIVILEGES",{raw: true, transaction });}),down: (q)=>q.sequelize.query("DROP USER IF EXISTS ?@?",{raw: true,replacements: ["test","localhost"],})};
Generated in such case SQL looks next:
CREATEUSERIF NOT EXISTS 'test'@? IDENTIFIED BY 'localhost';
What do you expect to happen?
Additional check should be added to parser to handle replacement constructions like this: "?@?".
What is actually happening?
Parser skips an occurrence of the second '?' in "?@?" and therefore inserts items of replacements array in a wrong order.
No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in resolving my issue.
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered:
Issue Creation Checklist
Bug Description
When creating a raw query, the parser can run into a situation when it skips a part of a query, which supposed to be replaced by values from REPLACEMENTS array.
Lets assume that a user trying to implement a seed like below:
Reproducible Example
Generated in such case SQL looks next:
What do you expect to happen?
Additional check should be added to parser to handle replacement constructions like this: "?@?".
What is actually happening?
Parser skips an occurrence of the second '?' in "?@?" and therefore inserts items of replacements array in a wrong order.
Environment
Sequelize version: sequelize@6.33.0
Node.js version: v18.18.0
Database & Version: mysql:8.0
Connector library & Version: mysql2@3.6.1
Issue file location: node_modules/sequelize/lib/utils/sql.js
Line number: starts at 139:
Code block snippet:
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: