-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Proposal to stop mixing limit
and offset
with the Range
header
#3007
Comments
This sounds like a great idea. It also has very nice semantics: Changing the URL actually changes the requested resource ("a list of 3" is a different thing from "a list of 5"), but using Range headers just "browses through the same resource". |
@laurenceisla Great idea! This will also make fixing the |
Hmm, this would take a lot of change since limit and range is currently too mixed up. For starters, how would you like the following data structures to change: -- data ApiRequest
...
, iRange :: HM.HashMap Text NonnegRange -- ^ Requested range of rows within response
, iTopLevelRange :: NonnegRange -- ^ Requested range of rows from the top level
... I think we can change them to two ranges, so one would represent the offset and limit range and other would represent the range header. So it may be like: -- data ApiRequest
...
, iOffsetLimit :: NonnegRange -- ^ Requested range of rows within the selected resource
, iHeaderRange :: NonnegRange -- ^ Requested range of rows from the selected resource
... |
Also, does this change mean we need to remove the |
Yes, it may need a fair amount of refactoring and/or redesign to be done.
It's a valid approach, although I remembered I wanted to send
According to what I described above then |
One important consideration for the example in the opening post: What will the Currently it would return 5 total rows, but if we clean this up, it should return 4 total rows. I.e. the row counting should only do so on the result of |
Problem
Range
goes against the RFC 7233 as it was mentioned in Shortcomings in HTTP compliance #1089.LIMIT 0
: Allow limit=0 in query params to return an empty array #2269Proposal
limit
andoffset
as-is to SQL, e.g.?offset=1&limit=3
toOFFSET 1 AND LIMIT 3
without taking into consideration the values inRange
. The query builder generates an aggregate query that should apply the value of theRange
, and the sub-query that should apply thelimit
andoffset
.200
instead of206
if it has noRange
header, complying with RFC 7233 section-4.1.Caveats
The selected resource will now include limits and offsets, so the
Range
values will apply over that selected resource, e.g. this query:Will no longer return
Instead, it will show:
It does not mix
offset=1
withRange: 1-
, it applies theoffset
first and then the first position range value over the already offset query.The text was updated successfully, but these errors were encountered: