{"action":"created","issue":{"url":"https://api.github.com/repos/sidorares/node-mysql2/issues/446","repository_url":"https://api.github.com/repos/sidorares/node-mysql2","labels_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/446/labels{/name}","comments_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/446/comments","events_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/446/events","html_url":"https://github.com/sidorares/node-mysql2/issues/446","id":186377796,"number":446,"title":"Problem using `execute` and boolean parameters","user":{"login":"joakimbeng","id":1427383,"avatar_url":"https://avatars.githubusercontent.com/u/1427383?v=3","gravatar_id":"","url":"https://api.github.com/users/joakimbeng","html_url":"https://github.com/joakimbeng","followers_url":"https://api.github.com/users/joakimbeng/followers","following_url":"https://api.github.com/users/joakimbeng/following{/other_user}","gists_url":"https://api.github.com/users/joakimbeng/gists{/gist_id}","starred_url":"https://api.github.com/users/joakimbeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joakimbeng/subscriptions","organizations_url":"https://api.github.com/users/joakimbeng/orgs","repos_url":"https://api.github.com/users/joakimbeng/repos","events_url":"https://api.github.com/users/joakimbeng/events{/privacy}","received_events_url":"https://api.github.com/users/joakimbeng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-31T19:41:11Z","updated_at":"2016-11-01T08:49:29Z","closed_at":null,"body":"First of all, great job with this module! It was a really smooth transition from the `mysql` module.\r\n\r\nNow to the problem...\r\n\r\nI have a table with a `isAddon TINYINT(1) NOT NULL` column.\r\n\r\nSuch a column is converted to a `boolean` when selecting from the table, but when using a `boolean` parameter to filter the table only works with the `query()` method and not `execute()`. I get the same result no matter if I pass `true` or `false` as a parameter, see example below.\r\n\r\n**This does not work:**\r\n\r\n```javascript\r\n// running a query where I want: isAddon=0\r\ndb.execute('select count(*) from MyTable where isAddon = ?', [false]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ BinaryRow { 'count(*)': 680 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n\r\n// running a query where I want: isAddon=1\r\n> db.execute('select count(*) from MyTable where isAddon = ?', [true]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ BinaryRow { 'count(*)': 680 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n```\r\n\r\nAs you can see the results are the same, I get `680` number of rows for both queries.\r\n\r\n**Using `query()` works:**\r\n\r\n```javascript\r\n// running the query where I want: isAddon=0\r\n> db.query('select count(*) from MyTable where isAddon = ?', [false]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ TextRow { 'count(*)': 680 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n\r\n// running the query where I want: isAddon=1\r\n> db.query('select count(*) from MyTable where isAddon = ?', [true]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ TextRow { 'count(*)': 7 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n```\r\n\r\nAs you can see I get different results, which are correct, `680` number of rows where `isAddon=0` and `7` rows where `isAddon=1`.\r\n\r\n**Converting `boolean`'s to `number`'s also work with `execute()`:**\r\n\r\n```javascript\r\n> db.execute('select count(*) from MyTable where isAddon = ?', [Number(false)]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ BinaryRow { 'count(*)': 680 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n\r\n> db.execute('select count(*) from MyTable where isAddon = ?', [Number(true)]).then(console.log)\r\nPromise { <pending> }\r\n> [ [ BinaryRow { 'count(*)': 7 } ],\r\n  [ { catalog: 'def',\r\n      schema: '',\r\n      name: 'count(*)',\r\n      orgName: '',\r\n      table: '',\r\n      orgTable: '',\r\n      characterSet: 63,\r\n      columnLength: 21,\r\n      columnType: 8,\r\n      flags: 129,\r\n      decimals: 0 } ] ]\r\n```\r\n\r\n---\r\n\r\nNodeJS version: `v6.7.0`  \r\nmysql2 version: `1.1.1`\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/sidorares/node-mysql2/issues/comments/257516241","html_url":"https://github.com/sidorares/node-mysql2/issues/446#issuecomment-257516241","issue_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/446","id":257516241,"user":{"login":"joakimbeng","id":1427383,"avatar_url":"https://avatars.githubusercontent.com/u/1427383?v=3","gravatar_id":"","url":"https://api.github.com/users/joakimbeng","html_url":"https://github.com/joakimbeng","followers_url":"https://api.github.com/users/joakimbeng/followers","following_url":"https://api.github.com/users/joakimbeng/following{/other_user}","gists_url":"https://api.github.com/users/joakimbeng/gists{/gist_id}","starred_url":"https://api.github.com/users/joakimbeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joakimbeng/subscriptions","organizations_url":"https://api.github.com/users/joakimbeng/orgs","repos_url":"https://api.github.com/users/joakimbeng/repos","events_url":"https://api.github.com/users/joakimbeng/events{/privacy}","received_events_url":"https://api.github.com/users/joakimbeng/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T08:49:29Z","updated_at":"2016-11-01T08:49:29Z","body":"IMO I think you should, because that would be inline with how `query` works."}}
{"actor":{"display_login":"joakimbeng"}}