Add ability to order by jsonb keys, fix #644

This commit is contained in:
SteveBash
2016-10-05 14:46:12 -05:00
parent 980680f3d6
commit 191601f129
6 changed files with 15 additions and 4 deletions
+8
View File
@@ -374,6 +374,14 @@ spec = do
, 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" $
get "/items?order=id.asc" `shouldRespondWith` 200
+2
View File
@@ -213,6 +213,8 @@ SELECT pg_catalog.setval('items_id_seq', 15, true);
TRUNCATE TABLE json CASCADE;
INSERT INTO json VALUES ('{"foo":{"bar":"baz"},"id":1}');
INSERT INTO json VALUES ('{"id":3}');
INSERT INTO json VALUES ('{"id":0}');
--