{"action":"opened","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1802","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1802/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1802/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1802/events","html_url":"https://github.com/tgriesser/knex/issues/1802","id":191497760,"number":1802,"title":"Knex.js raw() method returns additional data","user":{"login":"nicholaswmin","id":3926463,"avatar_url":"https://avatars.githubusercontent.com/u/3926463?v=3","gravatar_id":"","url":"https://api.github.com/users/nicholaswmin","html_url":"https://github.com/nicholaswmin","followers_url":"https://api.github.com/users/nicholaswmin/followers","following_url":"https://api.github.com/users/nicholaswmin/following{/other_user}","gists_url":"https://api.github.com/users/nicholaswmin/gists{/gist_id}","starred_url":"https://api.github.com/users/nicholaswmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicholaswmin/subscriptions","organizations_url":"https://api.github.com/users/nicholaswmin/orgs","repos_url":"https://api.github.com/users/nicholaswmin/repos","events_url":"https://api.github.com/users/nicholaswmin/events{/privacy}","received_events_url":"https://api.github.com/users/nicholaswmin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-24T11:33:13Z","updated_at":"2016-11-24T11:33:13Z","closed_at":null,"body":"I'm running a query using the `.raw()` method, using MySQL as the DB.\r\n\r\nInstead of returning the results of the query *only*, it also includes in the results some additional data I don't really need:\r\n\r\n### Query\r\n\r\n```sql\r\nconst query = SELECT idFoo AS \"Foo\",  DATE_FORMAT(bar, \"%m/%d/%Y\") AS \"Bar\" FROM baz\r\n```\r\n\r\nand then:\r\n\r\n```javascript\r\ndb.raw(query)\r\n.then((rows) => {\r\n  // @FIXME\r\n  // Knex returns a nested array when running `.raw()` with some\r\n  // unnecessary info, the actual contents are in the first element.\r\n  // Find out why & eliminate the `rows = rows[0]` redefinition below.\r\n  resolve(rows)\r\n})\r\n.catch((err) => reject(err));\r\n```\r\n\r\n### Result\r\n\r\n```javascript\r\n[\r\n // actual results I need\r\n  [ \r\n    {\r\n      \"Foo\": \"hqbmu\",\r\n      \"Bar\": \"02/04/2002\"\r\n    }\r\n  ],\r\n // unnecessary info\r\n  [\r\n    {\r\n      \"catalog\": \"def\",\r\n      \"db\": \"mydb\",\r\n      \"table\": \"baz\",\r\n      \"orgTable\": \"baz\",\r\n      \"name\": \"Foo\",\r\n      \"orgName\": \"idFoo\",\r\n      \"charsetNr\": 33,\r\n      \"length\": 135,\r\n      \"type\": 253,\r\n      \"flags\": 4097,\r\n      \"decimals\": 0,\r\n      \"zeroFill\": false,\r\n      \"protocol41\": true\r\n    },\r\n    {\r\n      \"catalog\": \"def\",\r\n      \"db\": \"\",\r\n      \"table\": \"\",\r\n      \"orgTable\": \"\",\r\n      \"name\": \"idBar\",\r\n      \"orgName\": \"\",\r\n      \"charsetNr\": 33,\r\n      \"length\": 30,\r\n      \"type\": 253,\r\n      \"flags\": 0,\r\n      \"decimals\": 0,\r\n      \"zeroFill\": false,\r\n      \"protocol41\": true\r\n    }\r\n  ]\r\n]\r\n```\r\n\r\n**Note:** I've replaced some sensitive table/column names in the output I've posted here."}}
{"actor":{"display_login":"nicholaswmin"}}