{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/797","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/797/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/797/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/797/events","html_url":"https://github.com/brianc/node-postgres/issues/797","id":84571093,"number":797,"title":"undefined bind vars result in: caught unhandled error error: syntax error at or near \"$1\"","user":{"login":"devTristan","id":216009,"avatar_url":"https://avatars.githubusercontent.com/u/216009?v=3","gravatar_id":"","url":"https://api.github.com/users/devTristan","html_url":"https://github.com/devTristan","followers_url":"https://api.github.com/users/devTristan/followers","following_url":"https://api.github.com/users/devTristan/following{/other_user}","gists_url":"https://api.github.com/users/devTristan/gists{/gist_id}","starred_url":"https://api.github.com/users/devTristan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devTristan/subscriptions","organizations_url":"https://api.github.com/users/devTristan/orgs","repos_url":"https://api.github.com/users/devTristan/repos","events_url":"https://api.github.com/users/devTristan/events{/privacy}","received_events_url":"https://api.github.com/users/devTristan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-03T13:42:33Z","updated_at":"2015-06-05T00:36:27Z","closed_at":null,"body":"```javascript```\r\nclient.query('SELECT * FROM stuff WHERE id=$1', [4]);\r\n```\r\nExpected behavior: `SELECT * FROM stuff WHERE id=4`\r\nActual behavior: `SELECT * FROM stuff WHERE id=4`\r\n:)\r\n\r\n```javascript```\r\nclient.query('SELECT * FROM stuff WHERE id=$1', []);\r\n```\r\nExpected behavior: exception thrown\r\nActual behavior: exception thrown\r\n:)\r\n\r\n```javascript```\r\nclient.query('SELECT * FROM stuff WHERE id=$1', [undefined]);\r\n```\r\nExpected behavior: exception thrown, OR `SELECT * FROM stuff WHERE id=null`\r\nActual behavior: `SELECT * FROM stuff WHERE id=$1`\r\n:(\r\n\r\nI don't know if there's any kind of specification for how bind vars should be treated in different situations. I know the practice has been around for a long time, so I feel like there might be.\r\n\r\nIf you think it's a good idea, I can send a pull request that results in errors being thrown when you try to use `undefined` as a bind var. Otherwise I'll go around checking all of my bind vars before I send them and I'll be sad, but not that sad, but a little sad."},"comment":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/comments/109104575","html_url":"https://github.com/brianc/node-postgres/issues/797#issuecomment-109104575","issue_url":"https://api.github.com/repos/brianc/node-postgres/issues/797","id":109104575,"user":{"login":"xaka","id":504813,"avatar_url":"https://avatars.githubusercontent.com/u/504813?v=3","gravatar_id":"","url":"https://api.github.com/users/xaka","html_url":"https://github.com/xaka","followers_url":"https://api.github.com/users/xaka/followers","following_url":"https://api.github.com/users/xaka/following{/other_user}","gists_url":"https://api.github.com/users/xaka/gists{/gist_id}","starred_url":"https://api.github.com/users/xaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xaka/subscriptions","organizations_url":"https://api.github.com/users/xaka/orgs","repos_url":"https://api.github.com/users/xaka/repos","events_url":"https://api.github.com/users/xaka/events{/privacy}","received_events_url":"https://api.github.com/users/xaka/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T00:36:27Z","updated_at":"2015-06-05T00:36:27Z","body":"The same here. I'd expect `undefined`/`null` to be equally treated as `NULL`. After switching to latest version of `node-postgres`, existing code stops working. "}}