{"action":"created","issue":{"url":"https://api.github.com/repos/Vincit/objection.js/issues/869","repository_url":"https://api.github.com/repos/Vincit/objection.js","labels_url":"https://api.github.com/repos/Vincit/objection.js/issues/869/labels{/name}","comments_url":"https://api.github.com/repos/Vincit/objection.js/issues/869/comments","events_url":"https://api.github.com/repos/Vincit/objection.js/issues/869/events","html_url":"https://github.com/Vincit/objection.js/issues/869","id":311890950,"number":869,"title":"Cannot use 'in' operator to search for 'key' in undefined","user":{"login":"igor-savin-ht","id":33480219,"avatar_url":"https://avatars2.githubusercontent.com/u/33480219?v=4","gravatar_id":"","url":"https://api.github.com/users/igor-savin-ht","html_url":"https://github.com/igor-savin-ht","followers_url":"https://api.github.com/users/igor-savin-ht/followers","following_url":"https://api.github.com/users/igor-savin-ht/following{/other_user}","gists_url":"https://api.github.com/users/igor-savin-ht/gists{/gist_id}","starred_url":"https://api.github.com/users/igor-savin-ht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igor-savin-ht/subscriptions","organizations_url":"https://api.github.com/users/igor-savin-ht/orgs","repos_url":"https://api.github.com/users/igor-savin-ht/repos","events_url":"https://api.github.com/users/igor-savin-ht/events{/privacy}","received_events_url":"https://api.github.com/users/igor-savin-ht/received_events","type":"User","site_admin":false},"labels":[{"id":199461320,"url":"https://api.github.com/repos/Vincit/objection.js/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-04-06T08:34:02Z","updated_at":"2018-04-06T11:46:39Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"EDIT BY @koskimas: This has been fixed in 1.1.3\r\n\r\nSeems to be a regression in 1.1.2.\r\n\r\nWhen calling JSON.stringify(entities); (which, e. g., happens when you are trying to send an array of Objection entities as a response from Express), an error is thrown.\r\nError seems to only manifest itself when entity in question has custom idColumn defined (in this particular case it was defined as\r\n```\r\n\tstatic get idColumn() {\r\n\t\treturn 'key';\r\n\t}\r\n```\r\n)\r\n\r\nError stacktrace:\r\n\r\nTypeError: Cannot use 'in' operator to search for 'key' in undefined\r\n    at assignJsonValue (C:\\sources\\lms-api\\models\\node_modules\\objection\\lib\\model\\modelToJson.js:79:33)\r\n    at toExternalJsonImpl (C:\\sources\\lms-api\\models\\node_modules\\objection\\lib\\model\\modelToJson.js:51:5)\r\n    at toJson (C:\\sources\\lms-api\\models\\node_modules\\objection\\lib\\model\\modelToJson.js:20:14)\r\n    at Brand.$toJson (C:\\sources\\lms-api\\models\\node_modules\\objection\\lib\\model\\Model.js:204:12)\r\n    at Brand.toJSON (C:\\sources\\lms-api\\models\\node_modules\\objection\\lib\\model\\Model.js:208:17)\r\n    at JSON.stringify (<anonymous>)\r\n    at eval (eval at stringify (C:\\sources\\lms-api\\api\\node_modules\\express\\lib\\response.js:1117:14), <anonymous>:1:6)\r\n    at stringify (C:\\sources\\lms-api\\api\\node_modules\\express\\lib\\response.js:1117:14)\r\n    at ServerResponse.json (C:\\sources\\lms-api\\api\\node_modules\\express\\lib\\response.js:260:14)\r\n    at ServerResponse.send (C:\\sources\\lms-api\\api\\node_modules\\express\\lib\\response.js:158:21)\r\n    at router.get (C:\\sources\\lms-api\\api\\controllers\\brands.controller.js:44:7)\r\n    at <anonymous>\r\n\r\nSurprisingly, this works fine when single entity is being stringified."},"comment":{"url":"https://api.github.com/repos/Vincit/objection.js/issues/comments/379229665","html_url":"https://github.com/Vincit/objection.js/issues/869#issuecomment-379229665","issue_url":"https://api.github.com/repos/Vincit/objection.js/issues/869","id":379229665,"user":{"login":"koskimas","id":846508,"avatar_url":"https://avatars2.githubusercontent.com/u/846508?v=4","gravatar_id":"","url":"https://api.github.com/users/koskimas","html_url":"https://github.com/koskimas","followers_url":"https://api.github.com/users/koskimas/followers","following_url":"https://api.github.com/users/koskimas/following{/other_user}","gists_url":"https://api.github.com/users/koskimas/gists{/gist_id}","starred_url":"https://api.github.com/users/koskimas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koskimas/subscriptions","organizations_url":"https://api.github.com/users/koskimas/orgs","repos_url":"https://api.github.com/users/koskimas/repos","events_url":"https://api.github.com/users/koskimas/events{/privacy}","received_events_url":"https://api.github.com/users/koskimas/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T11:46:39Z","updated_at":"2018-04-06T11:46:39Z","author_association":"CONTRIBUTOR","body":"@kibertoad Other people may have hit the same bug and they'll come looking for an answer. Let's keep this open for a couple of days."}}
{"actor":{"display_login":"koskimas"}}