@@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Implement support for singular representation responses for POST/PATCH requests - @ehamberg
|
- Implement support for singular representation responses for POST/PATCH requests - @ehamberg
|
||||||
- Include RPC endpoints in OpenAPI output - @begriffs, @LogvinovLeon
|
- Include RPC endpoints in OpenAPI output - @begriffs, @LogvinovLeon
|
||||||
- Custom request validation with `--pre-request` argument - @begriffs
|
- Custom request validation with `--pre-request` argument - @begriffs
|
||||||
|
- Ability to order by jsonb keys - @steve-chavez
|
||||||
- Ability to specify offset for a deeper level - @ruslantalpa
|
- Ability to specify offset for a deeper level - @ruslantalpa
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ pOrder = lexeme pOrderTerm `sepBy` char ','
|
|||||||
pOrderTerm :: Parser OrderTerm
|
pOrderTerm :: Parser OrderTerm
|
||||||
pOrderTerm =
|
pOrderTerm =
|
||||||
try ( do
|
try ( do
|
||||||
c <- pFieldName
|
c <- pField
|
||||||
d <- optionMaybe (try $ pDelimiter *> (
|
d <- optionMaybe (try $ pDelimiter *> (
|
||||||
try(string "asc" *> pure OrderAsc)
|
try(string "asc" *> pure OrderAsc)
|
||||||
<|> try(string "desc" *> pure OrderDesc)
|
<|> try(string "desc" *> pure OrderDesc)
|
||||||
@@ -147,4 +147,4 @@ pOrderTerm =
|
|||||||
))
|
))
|
||||||
return $ OrderTerm c d nls
|
return $ OrderTerm c d nls
|
||||||
)
|
)
|
||||||
<|> OrderTerm <$> (toS <$> pFieldName) <*> pure Nothing <*> pure Nothing
|
<|> OrderTerm <$> pField <*> pure Nothing <*> pure Nothing
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls conditions
|
|||||||
clause = intercalate "," (map queryTerm ts)
|
clause = intercalate "," (map queryTerm ts)
|
||||||
queryTerm :: OrderTerm -> Text
|
queryTerm :: OrderTerm -> Text
|
||||||
queryTerm t = " "
|
queryTerm t = " "
|
||||||
<> toS (pgFmtColumn qi $ otTerm t) <> " "
|
<> toS (pgFmtField qi $ otTerm t) <> " "
|
||||||
<> maybe "" show (otDirection t) <> " "
|
<> maybe "" show (otDirection t) <> " "
|
||||||
<> maybe "" show (otNullOrder t) <> " "
|
<> maybe "" show (otNullOrder t) <> " "
|
||||||
(joins, selects) = foldr getQueryParts ([],[]) forest
|
(joins, selects) = foldr getQueryParts ([],[]) forest
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ instance Show OrderNulls where
|
|||||||
show OrderNullsLast = "nulls last"
|
show OrderNullsLast = "nulls last"
|
||||||
|
|
||||||
data OrderTerm = OrderTerm {
|
data OrderTerm = OrderTerm {
|
||||||
otTerm :: Text
|
otTerm :: Field
|
||||||
, otDirection :: Maybe OrderDirection
|
, otDirection :: Maybe OrderDirection
|
||||||
, otNullOrder :: Maybe OrderNulls
|
, otNullOrder :: Maybe OrderNulls
|
||||||
} deriving (Show, Eq)
|
} deriving (Show, Eq)
|
||||||
|
|||||||
@@ -387,6 +387,14 @@ spec = do
|
|||||||
, matchHeaders = ["Content-Range" <:> "0-2/*"]
|
, matchHeaders = ["Content-Range" <:> "0-2/*"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it "by a json column property asc" $
|
||||||
|
get "/json?order=data->>id.asc" `shouldRespondWith`
|
||||||
|
[json| [{"data": {"id": 0}}, {"data": {"id": 1, "foo": {"bar": "baz"}}}, {"data": {"id": 3}}] |]
|
||||||
|
|
||||||
|
it "by a json column with two level property nulls first" $
|
||||||
|
get "/json?order=data->foo->>bar.nullsfirst" `shouldRespondWith`
|
||||||
|
[json| [{"data": {"id": 3}}, {"data": {"id": 0}}, {"data": {"id": 1, "foo": {"bar": "baz"}}}] |]
|
||||||
|
|
||||||
it "without other constraints" $
|
it "without other constraints" $
|
||||||
get "/items?order=id.asc" `shouldRespondWith` 200
|
get "/items?order=id.asc" `shouldRespondWith` 200
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -213,6 +213,8 @@ SELECT pg_catalog.setval('items_id_seq', 15, true);
|
|||||||
|
|
||||||
TRUNCATE TABLE json CASCADE;
|
TRUNCATE TABLE json CASCADE;
|
||||||
INSERT INTO json VALUES ('{"foo":{"bar":"baz"},"id":1}');
|
INSERT INTO json VALUES ('{"foo":{"bar":"baz"},"id":1}');
|
||||||
|
INSERT INTO json VALUES ('{"id":3}');
|
||||||
|
INSERT INTO json VALUES ('{"id":0}');
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user