-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Escaping fields is not working. #644
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
Comments
Confirm. I see the same behaviour. |
Please read the docs. You're using the API incorrectly: https://github.com/felixge/node-mysql#escaping-query-values |
Wait, wait.. Isn't that code do exactly the same thing that in your example? (Actually I've ran example and it not works to). This example: https://github.com/felixge/node-mysql#escaping-query-identifiers var userId = 1;
var columns = ['username', 'email'];
var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId], function(err, results) {
// ...
});
console.log(query.sql); // SELECT `username`, `email` FROM `users` WHERE id = 1 It actually can't replace |
Hello, |
It seems that I find it. The problem is in NPM package only. In GitHub version it's already fixed. So you can copy node-mysql/lib/protocol/SqlString.js from GitHub repository to your working directory and everything should be ok. I hope in NPM repository it would be fixed soon. |
Thank you, the Github version worked well. |
Just so everyone knows, the feature @yalamber is trying to use is a new feature that hasn't been released to npm yet (not a bug that hasn't been fixed yet). The feature is passing an array for |
Yes, but there is misleading docs if so. I mean.. in docs written: |
Yes, it may seem strange, but just like any project on GitHub.com, the README on the home page is about the latest code, not always the code you are using. The alpha9 documentation is at https://github.com/felixge/node-mysql/tree/v2.0.0-alpha9 |
Oh. Thanx. I didn't know that! |
This is on |
Hello,
I am using 2.0.0-alpha9 version of node-mysql below is my code where i am trying to escape the fields.
Above codes gives me following error:
TypeError: Object username,password has no method 'replace'
at Object.SqlString.escapeId (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/SqlString.js:7:20)
at /Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/SqlString.js:70:24
at String.replace (native)
at Object.SqlString.format (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/SqlString.js:64:14)
at PoolConnection.Connection.format (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/Connection.js:151:20)
at PoolConnection.Connection.query (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/Connection.js:106:20)
at /Users/yalambersubba/Sites/works/sconnect/api_server/tests/baseModelTest.js:39:20
at Pool. (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/Pool.js:52:14)
at Handshake.Sequence.end (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
at Handshake.Sequence.OkPacket (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/sequences/Sequence.js:84:8)
at Protocol._parsePacket (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/Protocol.js:172:24)
at Parser.write (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/Parser.js:62:12)
at Protocol.write (/Users/yalambersubba/Sites/works/sconnect/api_server/node_modules/mysql/lib/protocol/Protocol.js:37:16)
at Socket.ondata (stream.js:51:26)
at Socket.EventEmitter.emit (events.js:117:20)
at Socket. (stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
The text was updated successfully, but these errors were encountered: