{"action":"closed","issue":{"url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1359","repository_url":"https://api.github.com/repos/tgriesser/bookshelf","labels_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1359/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1359/comments","events_url":"https://api.github.com/repos/tgriesser/bookshelf/issues/1359/events","html_url":"https://github.com/tgriesser/bookshelf/issues/1359","id":173148547,"number":1359,"title":"Undefined binding(s) detected when compiling","user":{"login":"casoetan","id":1047316,"avatar_url":"https://avatars.githubusercontent.com/u/1047316?v=3","gravatar_id":"","url":"https://api.github.com/users/casoetan","html_url":"https://github.com/casoetan","followers_url":"https://api.github.com/users/casoetan/followers","following_url":"https://api.github.com/users/casoetan/following{/other_user}","gists_url":"https://api.github.com/users/casoetan/gists{/gist_id}","starred_url":"https://api.github.com/users/casoetan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/casoetan/subscriptions","organizations_url":"https://api.github.com/users/casoetan/orgs","repos_url":"https://api.github.com/users/casoetan/repos","events_url":"https://api.github.com/users/casoetan/events{/privacy}","received_events_url":"https://api.github.com/users/casoetan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tgriesser/bookshelf/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-25T08:57:31Z","updated_at":"2016-08-26T14:45:46Z","closed_at":"2016-08-26T14:45:46Z","body":"I've looked through all the issues raised here, and this does not seem to be covered, nor should it be happening, but it is to me.\r\n\r\nMy code\r\n```js\r\nlet User = bookshelf.Model.extend({\r\n  tableName: 'users',\r\n  hasTimestamps: true,\r\n  type: function() { return this.belongsTo(UserType) }\r\n}, {\r\n  findAll: Promise.method(args =>\r\n    User\r\n      .forge()\r\n      .fetchAll({ withRelated: 'type' })\r\n      .then(users => users.toJSON()))\r\n)\r\n```\r\n\r\nWithout the <code>{ withRelated: 'type' }</code> the code runs fine and all users are returned\r\n\r\n```json\r\n\"users\": [\r\n      {\r\n        \"id\": \"16\",\r\n        \"email\": \"user@coy.com\",\r\n        \"access_token\": \"quite long\",\r\n        \"confirmation_token\": \"\"\r\n      },\r\n      {\r\n        \"id\": \"22\",\r\n        \"email\": \"user2@coy.com\",\r\n        \"access_token\": null,\r\n        \"confirmation_token\": \"\"\r\n      }\r\n]\r\n```\r\n\r\nbut when I try to get the related type\r\n\r\n```json\r\n\"errors\": [\r\n    {\r\n      \"message\": \"Undefined binding(s) detected when compiling SELECT query: select `user_types`.* from `user_types` where `user_types`.`id` in (?)\",\r\n      \"locations\": [\r\n        {\r\n          \"line\": 38,\r\n          \"column\": 2\r\n        }\r\n      ],\r\n      \"stack\": \"Error: Undefined binding(s) detected when compiling SELECT query: select `user_types`.* from `user_types` where `user_types`.`id` in (?)\\n    at QueryCompiler_MySQL.toSQL...\"\r\n```\r\n\r\nThe debug output\r\n```js\r\n{ method: 'select',\r\n  options: {},\r\n  timeout: false,\r\n  cancelOnTimeout: false,\r\n  bindings: [],\r\n  __knexQueryUid: 'a733c03d-86c8-4cb7-8830-49ee6f629165',\r\n  sql: 'select `users`.* from `users`' }\r\n```\r\n\r\nWhat could be the issue. Been on this for hours now."}}
{"actor":{"display_login":"casoetan"}}