diff --git a/src/PostgREST/PgQuery.hs b/src/PostgREST/PgQuery.hs index 87cd58a85..966ec8243 100644 --- a/src/PostgREST/PgQuery.hs +++ b/src/PostgREST/PgQuery.hs @@ -337,7 +337,7 @@ countF :: T.Text countF = "pg_catalog.count(t)" countAllF :: T.Text -countAllF = "(SELECT pg_catalog.count(a) FROM (SELECT * FROM source) a )" +countAllF = "(SELECT pg_catalog.count(1) FROM (SELECT * FROM source) a )" countNoneF :: T.Text countNoneF = "null" diff --git a/test/Feature/InsertSpec.hs b/test/Feature/InsertSpec.hs index e4f042e04..dc7e835fb 100644 --- a/test/Feature/InsertSpec.hs +++ b/test/Feature/InsertSpec.hs @@ -121,12 +121,12 @@ spec = afterAll_ resetDb $ around withApp $ do after_ (clearTable "no_pk") . context "requesting full representation" $ do it "returns full details of inserted record" $ request methodPost "/no_pk" - [("Content-Type", "text/csv"), ("Prefer", "return=representation")] + [("Content-Type", "text/csv"), ("Accept", "text/csv"), ("Prefer", "return=representation")] "a,b\nbar,baz" `shouldRespondWith` ResponseMatcher { - matchBody = Just [json| { "a":"bar", "b":"baz" } |] + matchBody = Just "a,b\rbar,baz" , matchStatus = 201 - , matchHeaders = ["Content-Type" <:> "application/json", + , matchHeaders = ["Content-Type" <:> "text/csv", "Location" <:> "/no_pk?a=eq.bar&b=eq.baz"] } @@ -146,7 +146,7 @@ spec = afterAll_ resetDb $ around withApp $ do [("Content-Type", "text/csv"), ("Accept", "text/csv"), ("Prefer", "return=representation")] "a,b\nNULL,foo" `shouldRespondWith` ResponseMatcher { - matchBody = Just "a,b\n,foo" + matchBody = Just "a,b\r,foo" , matchStatus = 201 , matchHeaders = ["Content-Type" <:> "text/csv", "Location" <:> "/no_pk?a=is.null&b=eq.foo"] @@ -303,7 +303,7 @@ spec = afterAll_ resetDb $ around withApp $ do [ authHeaderBasic "jdoe" "1234", ("Prefer", "return=representation") ] [json| { "secret": "nyancat" } |] liftIO $ do - simpleBody p1 `shouldBe` [json| { "owner":"jdoe", "secret":"nyancat" } |] + simpleBody p1 `shouldBe` [str|{"owner":"jdoe","secret":"nyancat"}|] simpleStatus p1 `shouldBe` created201 p2 <- request methodPost "/authors_only" @@ -311,5 +311,5 @@ spec = afterAll_ resetDb $ around withApp $ do [ authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXN0X3Rlc3RfYXV0aG9yIiwiaWQiOiJqcm9lIn0.YuF_VfmyIxWyuceT7crnNKEprIYXsJAyXid3rjPjIow", ("Prefer", "return=representation") ] [json| { "secret": "lolcat", "owner": "hacker" } |] liftIO $ do - simpleBody p2 `shouldBe` [json| { "owner":"jroe", "secret":"lolcat" } |] + simpleBody p2 `shouldBe` [str|{"owner":"jroe","secret":"lolcat"}|] simpleStatus p2 `shouldBe` created201