{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/1148","labels_url":"https://api.github.com/repos/balderdashy/waterline/issues/1148/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline/issues/1148/comments","events_url":"https://api.github.com/repos/balderdashy/waterline/issues/1148/events","html_url":"https://github.com/balderdashy/waterline/pull/1148","id":106255018,"number":1148,"title":"Switch out Object.keys for _.keys in normalize","user":{"login":"zackehh","id":5376378,"avatar_url":"https://avatars.githubusercontent.com/u/5376378?v=3","gravatar_id":"","url":"https://api.github.com/users/zackehh","html_url":"https://github.com/zackehh","followers_url":"https://api.github.com/users/zackehh/followers","following_url":"https://api.github.com/users/zackehh/following{/other_user}","gists_url":"https://api.github.com/users/zackehh/gists{/gist_id}","starred_url":"https://api.github.com/users/zackehh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zackehh/subscriptions","organizations_url":"https://api.github.com/users/zackehh/orgs","repos_url":"https://api.github.com/users/zackehh/repos","events_url":"https://api.github.com/users/zackehh/events{/privacy}","received_events_url":"https://api.github.com/users/zackehh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-14T01:26:36Z","updated_at":"2015-10-19T05:13:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/balderdashy/waterline/pulls/1148","html_url":"https://github.com/balderdashy/waterline/pull/1148","diff_url":"https://github.com/balderdashy/waterline/pull/1148.diff","patch_url":"https://github.com/balderdashy/waterline/pull/1148.patch"},"body":"This may seem like an odd change, but it aids behaviour between different Node.js versions now that there are both ES5 and ES6 flavours out there.\r\n\r\n> In ES5, if the argument to this method is not an object (a primitive), then it will cause a TypeError. In ES6, a non-object argument will be coerced to an object.\r\n\r\nIn the current form if you pass something like `{ where: 'string' }` in Node.js 0.12.x, you will receive a `TypeError`, but in Node.js v4.x Waterline handles it according to ES6 and no `TypeError` is thrown - rather an error is generated elsewhere (haven't tracked it down) and **rejects the Promise**.\r\n\r\nNow, the ES6 behaviour is basically the same as what `_.keys` does, so this change enforces that both ES5 and ES6 will have the same effect here. It's much more convenient for those supporting both.\r\n\r\nFWIW I came across this with negative tests for a project; Node v4.x passed, v0.12.x failed - and the error isn't passed back to the Promise, which is what leads me to believe it should be fixed.\r\n\r\nI should also note that someone may want to improve how this works in future, but for the moment I think it's fine to just have parity."},"comment":{"url":"https://api.github.com/repos/balderdashy/waterline/issues/comments/149101688","html_url":"https://github.com/balderdashy/waterline/pull/1148#issuecomment-149101688","issue_url":"https://api.github.com/repos/balderdashy/waterline/issues/1148","id":149101688,"user":{"login":"tjwebb","id":1009114,"avatar_url":"https://avatars.githubusercontent.com/u/1009114?v=3","gravatar_id":"","url":"https://api.github.com/users/tjwebb","html_url":"https://github.com/tjwebb","followers_url":"https://api.github.com/users/tjwebb/followers","following_url":"https://api.github.com/users/tjwebb/following{/other_user}","gists_url":"https://api.github.com/users/tjwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/tjwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjwebb/subscriptions","organizations_url":"https://api.github.com/users/tjwebb/orgs","repos_url":"https://api.github.com/users/tjwebb/repos","events_url":"https://api.github.com/users/tjwebb/events{/privacy}","received_events_url":"https://api.github.com/users/tjwebb/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T05:13:52Z","updated_at":"2015-10-19T05:13:52Z","body":"> In the current form if you pass something like { where: 'string' } in Node.js 0.12.x, you will receive a TypeError, but in Node.js v4.x Waterline handles it according to ES6 and no TypeError is thrown - rather an error is generated elsewhere (haven't tracked it down) and rejects the Promise.\r\n\r\nI'm not quite sure what the material difference is, here. In ES6, a thrown error that is caught would result in a rejected Promise. Do you just not have access to the original error?"}}