@@ -175,6 +175,7 @@ wherePred (col, predicate) =
|
|||||||
"like" -> unknownLiteral $ T.map star value
|
"like" -> unknownLiteral $ T.map star value
|
||||||
"ilike" -> unknownLiteral $ T.map star value
|
"ilike" -> unknownLiteral $ T.map star value
|
||||||
"in" -> "(" <> T.intercalate ", " (map unknownLiteral $ T.split (==',') value) <> ") "
|
"in" -> "(" <> T.intercalate ", " (map unknownLiteral $ T.split (==',') value) <> ") "
|
||||||
|
"@@" -> "to_tsquery(" <> unknownLiteral value <> ") "
|
||||||
_ -> unknownLiteral value
|
_ -> unknownLiteral value
|
||||||
|
|
||||||
op = case opCode of
|
op = case opCode of
|
||||||
@@ -189,6 +190,7 @@ wherePred (col, predicate) =
|
|||||||
"in" -> "in"
|
"in" -> "in"
|
||||||
"is" -> "is"
|
"is" -> "is"
|
||||||
"isnot" -> "is not"
|
"isnot" -> "is not"
|
||||||
|
"@@" -> "@@"
|
||||||
_ -> "="
|
_ -> "="
|
||||||
|
|
||||||
orderParse :: Net.Query -> [OrderTerm]
|
orderParse :: Net.Query -> [OrderTerm]
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ spec =
|
|||||||
get "/simple_pk?k=ilike.*YY*&order=extra.asc" `shouldRespondWith`
|
get "/simple_pk?k=ilike.*YY*&order=extra.asc" `shouldRespondWith`
|
||||||
"[{\"k\":\"xyyx\",\"extra\":\"u\"},{\"k\":\"xYYx\",\"extra\":\"v\"}]"
|
"[{\"k\":\"xyyx\",\"extra\":\"u\"},{\"k\":\"xYYx\",\"extra\":\"v\"}]"
|
||||||
|
|
||||||
|
it "matches with tsearch @@" $
|
||||||
|
get "/tsearch?text_search_vector=@@.foo" `shouldRespondWith`
|
||||||
|
"[{\"text_search_vector\":\"'bar':2 'foo':1\"}]"
|
||||||
|
|
||||||
describe "ordering response" $ do
|
describe "ordering response" $ do
|
||||||
it "by a column asc" $
|
it "by a column asc" $
|
||||||
get "/items?id=lte.2&order=id.asc"
|
get "/items?id=lte.2&order=id.asc"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ spec = around withApp $ do
|
|||||||
, {"schema":"1","name":"menagerie","insertable":true}
|
, {"schema":"1","name":"menagerie","insertable":true}
|
||||||
, {"schema":"1","name":"no_pk","insertable":true}
|
, {"schema":"1","name":"no_pk","insertable":true}
|
||||||
, {"schema":"1","name":"simple_pk","insertable":true}
|
, {"schema":"1","name":"simple_pk","insertable":true}
|
||||||
|
, {"schema":"1","name":"tsearch","insertable":true}
|
||||||
] |]
|
] |]
|
||||||
{matchStatus = 200}
|
{matchStatus = 200}
|
||||||
|
|
||||||
|
|||||||
Vendored
+15
-8
@@ -212,6 +212,12 @@ CREATE TABLE json
|
|||||||
ALTER TABLE "1".json OWNER TO postgrest_test;
|
ALTER TABLE "1".json OWNER TO postgrest_test;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE tsearch (
|
||||||
|
text_search_vector tsvector
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE "1".tsearch OWNER TO postgrest_test;
|
||||||
|
|
||||||
SET search_path = postgrest, pg_catalog;
|
SET search_path = postgrest, pg_catalog;
|
||||||
|
|
||||||
|
|
||||||
@@ -299,14 +305,8 @@ INSERT INTO items (id) VALUES (1);
|
|||||||
SELECT pg_catalog.setval('items_id_seq', 1, true);
|
SELECT pg_catalog.setval('items_id_seq', 1, true);
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO tsearch (text_search_vector) VALUES ('''bar'':2 ''foo'':1');
|
||||||
|
INSERT INTO tsearch (text_search_vector) VALUES ('''baz'':1 ''qux'':2');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SET search_path = postgrest, pg_catalog;
|
SET search_path = postgrest, pg_catalog;
|
||||||
|
|
||||||
@@ -491,6 +491,13 @@ GRANT ALL ON TABLE json TO postgrest_test;
|
|||||||
GRANT ALL ON TABLE json TO postgrest_anonymous;
|
GRANT ALL ON TABLE json TO postgrest_anonymous;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
REVOKE ALL ON TABLE tsearch FROM PUBLIC;
|
||||||
|
REVOKE ALL ON TABLE tsearch FROM postgrest_test;
|
||||||
|
GRANT ALL ON TABLE tsearch TO postgrest_test;
|
||||||
|
GRANT ALL ON TABLE tsearch TO postgrest_anonymous;
|
||||||
|
|
||||||
|
|
||||||
SET search_path = postgrest, pg_catalog;
|
SET search_path = postgrest, pg_catalog;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user