Update json rpc argument tests for bugfix in PostgreSQL 11.4
See https://www.postgresql.org/docs/release/11.4/.
This commit is contained in:
committed by
Steve Chávez
parent
296a12e394
commit
4cc91fd5b1
@@ -429,6 +429,9 @@ pgVersion100 = PgVersion 100000 "10"
|
|||||||
pgVersion112 :: PgVersion
|
pgVersion112 :: PgVersion
|
||||||
pgVersion112 = PgVersion 110002 "11.2"
|
pgVersion112 = PgVersion 110002 "11.2"
|
||||||
|
|
||||||
|
pgVersion114 :: PgVersion
|
||||||
|
pgVersion114 = PgVersion 110004 "11.4"
|
||||||
|
|
||||||
sourceCTEName :: SqlFragment
|
sourceCTEName :: SqlFragment
|
||||||
sourceCTEName = "pg_source"
|
sourceCTEName = "pg_source"
|
||||||
|
|
||||||
|
|||||||
+10
-14
@@ -11,8 +11,8 @@ import Test.Hspec.Wai
|
|||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
import Text.Heredoc
|
import Text.Heredoc
|
||||||
|
|
||||||
import PostgREST.Types (PgVersion, pgVersion100, pgVersion95,
|
import PostgREST.Types (PgVersion, pgVersion100, pgVersion114,
|
||||||
pgVersion96)
|
pgVersion95)
|
||||||
import Protolude hiding (get)
|
import Protolude hiding (get)
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
|
|
||||||
@@ -256,30 +256,26 @@ spec actualPgVersion =
|
|||||||
[json|"object"|]
|
[json|"object"|]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
when (actualPgVersion <= pgVersion96) $
|
when (actualPgVersion < pgVersion100) $
|
||||||
it "parses quoted JSON arguments as JSON (Postgres <= 9.6)" $
|
it "parses quoted JSON arguments as JSON (Postgres < 10)" $
|
||||||
post "/rpc/json_argument"
|
post "/rpc/json_argument"
|
||||||
[json| { "arg": "{ \"key\": 3 }" } |]
|
[json| { "arg": "{ \"key\": 3 }" } |]
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
[json|"object"|]
|
[json|"object"|]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
when (actualPgVersion >= pgVersion100) $ do
|
when (actualPgVersion >= pgVersion114) $
|
||||||
it "parses quoted JSON arguments as JSON string (Postgres >= 10)" $ do
|
it "parses quoted JSON arguments as JSON string (Postgres >= 11.4)" $
|
||||||
-- Postgres bug report:
|
|
||||||
-- https://www.postgresql.org/message-id/D6921B37-BD8E-4664-8D5F-DB3525765DCD%40vllmrt.net
|
|
||||||
-- * json_to_record fails (see following test)
|
|
||||||
-- * jsonb_to_record parses the embedded quoted JSON to a JSON string,
|
|
||||||
-- so that's probably the expected behavior for Postgres >= 10
|
|
||||||
pendingWith "Postgres >= 10 fails to parse quoted embedded JSON"
|
|
||||||
post "/rpc/json_argument"
|
post "/rpc/json_argument"
|
||||||
[json| { "arg": "{ \"key\": 3 }" } |]
|
[json| { "arg": "{ \"key\": 3 }" } |]
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
[json|"string"|]
|
[json|"string"|]
|
||||||
{ matchHeaders = [matchContentTypeJson] }
|
{ matchHeaders = [matchContentTypeJson] }
|
||||||
|
|
||||||
it "fails to parse quoted JSON arguments (Postgres >= 10)" $
|
when (actualPgVersion >= pgVersion100 && actualPgVersion < pgVersion114) $
|
||||||
-- Confirming buggy Postgres behavior (see previous test)
|
it "fails to parse quoted JSON arguments (Postgres >= 10, < 11.4)" $
|
||||||
|
-- Confirming buggy Postgres behavior:
|
||||||
|
-- https://www.postgresql.org/message-id/D6921B37-BD8E-4664-8D5F-DB3525765DCD%40vllmrt.net
|
||||||
post "/rpc/json_argument"
|
post "/rpc/json_argument"
|
||||||
[json| { "arg": "{ \"key\": 3 }" } |]
|
[json| { "arg": "{ \"key\": 3 }" } |]
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
|
|||||||
Reference in New Issue
Block a user