{"action":"opened","issue":{"url":"https://api.github.com/repos/sidorares/node-mysql2/issues/348","repository_url":"https://api.github.com/repos/sidorares/node-mysql2","labels_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/348/labels{/name}","comments_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/348/comments","events_url":"https://api.github.com/repos/sidorares/node-mysql2/issues/348/events","html_url":"https://github.com/sidorares/node-mysql2/issues/348","id":166621980,"number":348,"title":"JSON_EXTRACT comparison/casting issue","user":{"login":"KevinMartin","id":510957,"avatar_url":"https://avatars.githubusercontent.com/u/510957?v=3","gravatar_id":"","url":"https://api.github.com/users/KevinMartin","html_url":"https://github.com/KevinMartin","followers_url":"https://api.github.com/users/KevinMartin/followers","following_url":"https://api.github.com/users/KevinMartin/following{/other_user}","gists_url":"https://api.github.com/users/KevinMartin/gists{/gist_id}","starred_url":"https://api.github.com/users/KevinMartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KevinMartin/subscriptions","organizations_url":"https://api.github.com/users/KevinMartin/orgs","repos_url":"https://api.github.com/users/KevinMartin/repos","events_url":"https://api.github.com/users/KevinMartin/events{/privacy}","received_events_url":"https://api.github.com/users/KevinMartin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-20T16:15:51Z","updated_at":"2016-07-20T16:15:51Z","closed_at":null,"body":"Using MySQL 5.7, it seems like calling `JSON_EXTRACT(field, path+)` for an integer from a json array isn't allowing me to compare with an integer.\r\n\r\nQuery:\r\n```sql\r\nSELECT *\r\nFROM table\r\nWHERE JSON_EXTRACT(json, \"$[2]\") >= ?;\r\n```\r\n\r\nThe value in the `json` field is just a simple `[1,2,3,4,5]`.\r\n\r\nI try executing the query with both a string and integer value. Both result in now results.\r\n\r\nIf I insert the query into MySQL Workbench, it works fine. If I screw the prepared statement route and just put the integer in the query in place of the `?`, it works fine.\r\n\r\nThey way around it so far is casting the `JSON_EXTRACT` value into `UNSIGNED` for the comparison to work:\r\n```sql\r\nSELECT *\r\nFROM table\r\nWHERE CAST(JSON_EXTRACT(json, \"$[2]\") AS UNSIGNED) >= ?;\r\n```"}}
{"actor":{"display_login":"KevinMartin"}}