feat: allow unknown on the is operator

Also make the IS values strict at the Parser level since IS cannot be
parametrized.
This commit is contained in:
steve-chavez
2021-11-18 17:01:58 -05:00
committed by Steve Chavez
parent 91689e28f0
commit bae5afbad6
8 changed files with 60 additions and 12 deletions
+17
View File
@@ -73,6 +73,23 @@ spec actualPgVersion = do
get "/nullable_integer?a=is.null" `shouldRespondWith` [json|[{"a":null}]|]
it "matches with trilean values" $ do
get "/chores?done=is.true" `shouldRespondWith`
[json| [{"id": 1, "name": "take out the garbage", "done": true }] |]
{ matchHeaders = [matchContentTypeJson] }
get "/chores?done=is.false" `shouldRespondWith`
[json| [{"id": 2, "name": "do the laundry", "done": false }] |]
{ matchHeaders = [matchContentTypeJson] }
get "/chores?done=is.unknown" `shouldRespondWith`
[json| [{"id": 3, "name": "wash the dishes", "done": null }] |]
{ matchHeaders = [matchContentTypeJson] }
it "fails if 'is' used and there's no null or trilean value" $ do
get "/chores?done=is.nil" `shouldRespondWith` 400
get "/chores?done=is.ok" `shouldRespondWith` 400
it "matches with like" $ do
get "/simple_pk?k=like.*yx" `shouldRespondWith`
[json|[{"k":"xyyx","extra":"u"}]|]
+3
View File
@@ -727,3 +727,6 @@ INSERT INTO test.contact (id,name, clientid) values (1,'Wally Walton',1),(2,'Wil
TRUNCATE TABLE test.clientinfo CASCADE;
INSERT INTO test.clientinfo (id,clientid, other) values (1,1,'123 Main St'),(2,2,'456 South 3rd St'),(3,3,'789 Palm Tree Ln');
TRUNCATE TABLE test.chores CASCADE;
INSERT INTO test.chores (id, name, done) values (1, 'take out the garbage', true), (2, 'do the laundry', false), (3, 'wash the dishes', null);
+2 -1
View File
@@ -159,6 +159,7 @@ GRANT ALL ON TABLE
, client
, clientinfo
, contact
, chores
TO postgrest_test_anonymous;
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
@@ -213,4 +214,4 @@ DO $do$BEGIN
GRANT ALL ON TABLE test.car_models_car_dealers_10to20 TO postgrest_test_anonymous;
GRANT ALL ON TABLE test.car_models_car_dealers_default TO postgrest_test_anonymous;
END IF;
END$do$;
END$do$;
+6
View File
@@ -2417,3 +2417,9 @@ CREATE TABLE clientinfo (
, clientid int unique references client(id)
, other text
);
CREATE TABLE chores (
id int primary key
, name text
, done bool
);