-
Notifications
You must be signed in to change notification settings - Fork 44
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
Sorting on unknown properties: returning Bad Request when appropriate #424
Conversation
Codecov Report
@@ Coverage Diff @@
## master #424 +/- ##
==========================================
+ Coverage 90.95% 91.40% +0.44%
==========================================
Files 56 56
Lines 2632 2653 +21
==========================================
+ Hits 2394 2425 +31
+ Misses 238 228 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
1fe2861
to
419341c
Compare
c6f5fc4
to
a8163ed
Compare
1411a13
to
ad2aa50
Compare
Just to be certain, your definitions of the three classes are something like the following:
|
I don't think I agree with this response, as it represents a well-formed and correctly valued request from the point of view of the specification, but will result in the return of different response codes depending on the implementation that is queried.
Yes, for any unknown (not "other provider" field) a
As with my suggestion for 2. above, I think this should return exactly what you have intended here, but also include a warning that I think I should really start working on that warnings addition system ... |
Agree this one can be interpreted many different ways. Thinking about use cases, if sorting is requested, I agree that at least a warning should be returned, but until we have that in, I would rather return a bad request. This is perhaps something that should be clarified in 1.0.1 of the spec.
Agreed and agreed 😁 |
Warnings will be implemented by #431 :)
See #431 ! 😄 |
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.
Thank @ml-evs !
So I've digged quite hard into the doc strings in this one.
I think I would prefer American diction and syntax as this was also the choice for the specification. If you strongly feel for the British syntax, then that's also fine by me, we just need to do one or the other.
After colons, I think starting with a capital letter looks nicer in the docs and makes more sense as well syntactically, no?
Concerning the move to an abstract class that's fine. However, I think you've moved over a bit more than what is needed? As soon as something is pymongo
-specific, it should probably be kept in the MongoCollection
? Or what is your rationale here?
I see that for much of it, it could actually serve as a general method, however, since it's not compeltely severed, I would prefer either moving it back or doing a mix of the two and properly splitting up the backend-specific stuff from the -agnostic.
I can't say I'd given these much thought, so happy either way.
My rationale was that the "pymongo-specific" handling is probably already a useful start point for other collections, and I wanted to avoid spawning loads of methods for every query parameter. I'll see how tasty the mixed approach gets, as I update this PR to include warnings for case 2. discussed in the OP. |
ad2aa50
to
454b271
Compare
e5ab87a
to
0911b18
Compare
I would more say to add a warning and use the known And the same for case 4 above. But here, since there are no valid |
That's what I've implemented right? |
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.
Using a regex here should be a bit better?
Yes you have. Sorry :) |
120c508
to
ef8948d
Compare
- Moved many generic methods from `MongoCollection` into base class - Moved and renamed `MongoCollection._parse_params(...)` to base class `EntryCollection.handle_query_params(...). - Refactored query params parsing into multiple methods. - Cache list of field names with property `.all_fields`. - `EntryCollection` no longer inherits from typing.Collection. - Removed dunder methods required to inherit from typing.Collection. - Improved docstrings
Co-authored-by: Casper Welzel Andersen <[email protected]>
Co-authored-by: Casper Welzel Andersen <[email protected]>
ef8948d
to
0210427
Compare
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 would approve, if it wasn't for an unnecessary use of the structures
fixture in one of the tests, which should definitely be removed.
Then it's essentially good to go.
All the other comments are merely suggestions.
Co-authored-by: Casper Welzel Andersen <[email protected]>
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.
This is good to go from my side now, thanks for the hard work @ml-evs ! 👍 💪
This PR enables
400: Bad Request
s to be returned when requesting unknown fields. The specification provides a little bit of flexibility here, so I'll illustrate my approach with a few cases, with three classes of fields: known, unknown and "other provider" (those prefixed by_
with no known alias):sort=foo,bar
.sort=_exmpl_foo,_exmpl_bar
.sort=nelements,foo
.sort=nelements,_exmpl_foo
.Closes #276.
To-do: