Regression test for situation reported in issue #203

This commit is contained in:
Joe Nelson
2015-07-03 22:51:04 -07:00
parent df04d26c15
commit 956f73d997
4 changed files with 27 additions and 2 deletions
+4 -1
View File
@@ -10,6 +10,7 @@ import SpecHelper
spec :: Spec
spec =
beforeAll (clearTable "items" >> createItems 15)
. beforeAll (clearTable "nullable_integer" >> createNullInteger)
. beforeAll (
clearTable "no_pk" >>
createNulls 2 >>
@@ -38,10 +39,12 @@ spec =
, matchHeaders = ["Content-Range" <:> "0-2/3"]
}
it "matches nulls" $
it "matches nulls in varchar and numeric fields alike" $ do
get "/no_pk?a=is.null" `shouldRespondWith`
[json| [{"a": null, "b": null}] |]
get "/nullable_integer?a=is.null" `shouldRespondWith` "[{\"a\":null}]"
it "matches with like" $ do
get "/simple_pk?k=like.*yx" `shouldRespondWith`
"[{\"k\":\"xyyx\",\"extra\":\"u\"}]"
+1
View File
@@ -22,6 +22,7 @@ spec = around withApp $ do
, {"schema":"1","name":"json","insertable":true}
, {"schema":"1","name":"menagerie","insertable":true}
, {"schema":"1","name":"no_pk","insertable":true}
, {"schema":"1","name":"nullable_integer","insertable":true}
, {"schema":"1","name":"simple_pk","insertable":true}
, {"schema":"1","name":"tsearch","insertable":true}
] |]
+7 -1
View File
@@ -94,7 +94,7 @@ matchHeader name valRegex headers =
authHeaderBasic :: String -> String -> Header
authHeaderBasic u p =
(hAuthorization, cs $ "Basic " ++ encode (u ++ ":" ++ p))
authHeaderJWT :: String -> Header
authHeaderJWT token =
(hAuthorization, cs $ "Bearer " ++ token)
@@ -125,6 +125,12 @@ createNulls n = do
stmt' = [H.stmt|insert into "1".no_pk (a,b) values (null,null)|]
stmts = map [H.stmt|insert into "1".no_pk (a,b) values (?,0)|] [1..n]
createNullInteger :: IO ()
createNullInteger = do
pool <- testPool
void . liftIO $ H.session pool $ H.tx Nothing $
H.unitEx $ [H.stmt| insert into "1".nullable_integer (a) values (null) |]
createLikableStrings :: IO ()
createLikableStrings = do
pool <- testPool
+15
View File
@@ -230,6 +230,14 @@ CREATE TABLE no_pk (
ALTER TABLE "1".no_pk OWNER TO postgrest_test;
CREATE TABLE nullable_integer (
a integer
);
ALTER TABLE "1".nullable_integer OWNER TO postgrest_test;
CREATE TABLE simple_pk (
k character varying NOT NULL,
extra character varying NOT NULL
@@ -518,6 +526,13 @@ GRANT ALL ON TABLE no_pk TO postgrest_anonymous;
REVOKE ALL ON TABLE nullable_integer FROM PUBLIC;
REVOKE ALL ON TABLE nullable_integer FROM postgrest_test;
GRANT ALL ON TABLE nullable_integer TO postgrest_test;
GRANT ALL ON TABLE nullable_integer TO postgrest_anonymous;
REVOKE ALL ON TABLE simple_pk FROM PUBLIC;
REVOKE ALL ON TABLE simple_pk FROM postgrest_test;
GRANT ALL ON TABLE simple_pk TO postgrest_test;