New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't trigger findAll
when Model.find()
is called with a null
or undefined
parameter
#518
Conversation
…s called, rather than triggering a `findAll`
if ('undefined' === typeof id || id === null) { | ||
throw new Ember.Error(fmt('Cannot find %@ for type %@.', [id + '', type])); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe be an Ember.assert instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did it this way because the issue popped up in prod for us (we did not pass undefined in intentionally). The error message we got was not very useful in tracking it down.
I think most of the code for these kinds of cases uses assert so I would prefer that we keep doing it that way. Would be happy to merge it once that's changed.Thanks! |
Asserts are removed in prod builds right? I think that won't be particularly helpful. Developers aren't intentionally passing I honestly wonder if having I paired with @stefanpenner on this. |
Agreed that this should be an |
I don't like overloading |
thoughts for discussion. ray's addition is legit, this is an actual runtime error.
Proposal:
|
Instead throw an error. This is a much easier way to understand that you're passing a bad value to
Model.find
so in the new behavior: