mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.22k stars 2.53k forks source link

Placeholder is not working when used using prepared statement #2506

Closed zer09 closed 2 years ago

zer09 commented 2 years ago

With this query

SELECT ??
FROM ??
WHERE id=?

This will perfectly works if executed like this

connectionPool.query<RowDataPacket[]>(query, [arrayOfColumns,tableName,id])

But when used like this

connectionPool.execute<RowDataPacket[]>(query, [arrayOfColumns,tableName,id])

I am getting this

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?\\nFROM ??\\nWHERE id=?
dougwilson commented 2 years ago

This module has no method named execute.

zer09 commented 2 years ago

Sorry it should be on node-mysql2. I created new issue there https://github.com/sidorares/node-mysql2/issues/1356#issue-944434972