ConvertNulltoNotFoundError when calling DataAccessObject.findOne via rest#135
Merged
raymondfeng merged 1 commit intoloopbackio:masterfrom Jun 19, 2014
albertoleal:ConvertNullToNotFoundError
Merged
ConvertNulltoNotFoundError when calling DataAccessObject.findOne via rest#135raymondfeng merged 1 commit intoloopbackio:masterfrom albertoleal:ConvertNullToNotFoundError
raymondfeng merged 1 commit intoloopbackio:masterfrom
albertoleal:ConvertNullToNotFoundError
Conversation
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
Contributor
Author
|
Hi, do you any feedback about this pr? |
Contributor
|
Thanks for the patch. I'm not fully convinced whether reporting 404 is a good idea for findOne when no records are found. Maybe we should have a discussion on the group. |
Contributor
Author
|
I understand that we should discuss about it on the group, but that's the same behavior we have for findById. |
|
I agree with @albertoleal, the message we're passing when we return a success response in this case is that the object exists and it is A client should be able to consume both a findById URL and a findOne URL seamlessly with the same implementation. Right now it has to deal with a success, a null success and errors. |
raymondfeng
added a commit
that referenced
this pull request
Jun 19, 2014
ConvertNulltoNotFoundError when calling DataAccessObject.findOne via rest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When we call the url
http://localhost:3000/api/cars/1with an invalid id we get a 404 error:But, when we try to use filters, such as
http://localhost:3000/api/cars/findOne?filter%5Bwhere%5D%5Bid%5D=1, we have another behavior:nullThis PR follows the same approach found in: https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L364-L371