Prepared statement does not work for Symbol operators
See original GitHub issueWhat are you doing?
class User extends Model {}
User.init({
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
email: { type: DataTypes.STRING },
failed_logins: { type: DataTypes.INTEGER }
}, {
sequelize,
tableName: 'users'
});
What do you expect to happen?
await User.update({
failed_logins: 0
}, {
where: {
id: 1,
failed_logins: { [Op.eq]: 4 }
}
});
Mysql general_log
shows
# Actual
Prepare | UPDATE `users` SET `failed_logins`=? WHERE `id` = ? AND `failed_logins` = 4
But it is expected that failed_logins = ?
# Expected
Prepare | UPDATE `users` SET `failed_logins`=? WHERE `id` = ? AND `failed_logins` = ?
Environment
Dialect:
- mysql
- postgres
- sqlite
- mssql
- any Dialect mysql2 version: 1.6.5 Database version: 8.0.14 Sequelize version: 5.8.6 Node Version: v10.15.0 OS: Win10
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Cannot run prepared statement/function in postgres
you don't execute prepared statement when you select EXECUTE(get_account("A200")); - you execute your function. Here's example of how to run ...
Read more >Db2 12 - Db2 SQL - PREPARE - IBM
The PREPARE statement creates an executable SQL statement from a string form of the statement. The character-string form is called a statement string....
Read more >PREPARE | Pivotal Greenplum Docs
Description. PREPARE creates a prepared statement. A prepared statement is a server-side object that can be used to optimize performance.
Read more >MySQL 8.0 Reference Manual :: 13.5 Prepared Statements
SQL syntax for prepared statements can be used within stored procedures, but not in stored functions or triggers. However, a cursor cannot be...
Read more >Prepared statements and stored procedures - Manual - PHP
it is a good practice not using double quotes in sql strings. This way you can ensure that no variable is injected in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That issue about prepared statements not being cleared is being tracked here: https://github.com/sequelize/sequelize/issues/10832, I’ll post a status update over there
The substituted parameter values inside prepared statements cause prepared statements to leak inside db. To release them, the db connection has to be closed.
The db connections are typically closed on connection options.pool.idle timeout. But when the workload is able to keep all options.pool.max connections busy for long enough time, eventually the (in case of mysql) sysvar_max_prepared_stmt_count limit is reached and all subsequent db requests are denied with
Can't create more than max_prepared_stmt_count statements
.Is there a way to prevent this problem?