Fix count=none when we have filters
This commit is contained in:
@@ -66,11 +66,9 @@ app conf reqBody req =
|
|||||||
from = fromMaybe 0 $ rangeOffset <$> range
|
from = fromMaybe 0 $ rangeOffset <$> range
|
||||||
count = if hasPrefer "count=none"
|
count = if hasPrefer "count=none"
|
||||||
then countNone
|
then countNone
|
||||||
else countRows qt
|
else whereT qt qq $ countRows qt
|
||||||
query = B.Stmt "select " V.empty True <>
|
query = B.Stmt "select " V.empty True <>
|
||||||
parentheticT (
|
parentheticT count <> commaq <> (
|
||||||
whereT qt qq count
|
|
||||||
) <> commaq <> (
|
|
||||||
bodyForAccept contentType qt
|
bodyForAccept contentType qt
|
||||||
. limitT range
|
. limitT range
|
||||||
. orderT (orderParse qq)
|
. orderT (orderParse qq)
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable
|
|||||||
, matchHeaders = ["Content-Range" <:> "0-14/*"]
|
, matchHeaders = ["Content-Range" <:> "0-14/*"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it "returns range Content-Range with range/* even using other filters" $
|
||||||
|
request methodGet "/items?id=eq.1&order=id"
|
||||||
|
[("Prefer", "count=none")] ""
|
||||||
|
`shouldRespondWith` ResponseMatcher {
|
||||||
|
matchBody = Just [json| [{"id":1}] |]
|
||||||
|
, matchStatus = 200
|
||||||
|
, matchHeaders = ["Content-Range" <:> "0-0/*"]
|
||||||
|
}
|
||||||
|
|
||||||
context "with range headers" $ do
|
context "with range headers" $ do
|
||||||
|
|
||||||
context "of acceptable range" $ do
|
context "of acceptable range" $ do
|
||||||
|
|||||||
Reference in New Issue
Block a user