-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Undefined query parameters causes crash #55
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
For what it's worth, for inputs I'd treat undefined as a null value. It also makes it a one line change to fix at that point I believe :) |
I think undefined should probably be treated as null. I've bit bitten by On Wed, Oct 12, 2011 at 9:46 PM, Brian Dunavant <
|
Sure! Sounds like fun. |
The response for this is in issue #56 which got created when I submitted the code. Sorry, didn't know how to make it reference this issue. |
Closing since this fix was merged in #56 |
* Bump version of pg-cursor This includes fixes in [email protected]. I've relaxed semver a touch so I don't have to release a new version here just for patch changes to pg-cursor. * Pass options to pg-cursor fixes #55
If you pass an undefined value as a parameter to a query it crashes when trying to bind. Unfortunately with a stack trace that makes it very difficult to find your error (at least without putting console.logs inside of _pulseQuery to figure out which query is running).
Not sure what the correct solution would be here. Treat it as NULL? Throw an error?
Test case:
var pg = require('pg');
var conString = "tcp://user:pass@localhost/postgres";
pg.connect( conString, function(err, client) {
client.query("select $1 as foo", [ undefined ], function(err, result) {
console.log(result.rows[0].foo);
});
});
Crash output:
TypeError: Cannot call method 'toString' of undefined
at [object Object].bind (/Users/brian/node_modules/pg/lib/connection.js:138:17)
at [object Object].prepare (/Users/brian/node_modules/pg/lib/query.js:136:14)
at [object Object].submit (/Users/brian/node_modules/pg/lib/query.js:95:10)
at [object Object]._pulseQueryQueue (/Users/brian/node_modules/pg/lib/client.js:140:24)
at [object Object].query (/Users/brian/node_modules/pg/lib/client.js:164:8)
at assign_pending_items (/Users/brian/lucre/app.js:291:8)
at /Users/brian/lucre/app.js:213:3
at callbacks (/Users/brian/node_modules/express/lib/router/index.js:272:11)
at requireLogin (/Users/brian/lucre/app.js:46:3)
at callbacks (/Users/brian/node_modules/express/lib/router/index.js:272:11)
The text was updated successfully, but these errors were encountered: