module Pqi.Conformance.Operation.Paramtype
( spec,
)
where
import qualified Pqi
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
import Pqi.Conformance.Scenario (int8Oid)
import Test.Hspec
spec :: Pqi.Adapter -> SpecWith ByteString
spec :: Adapter -> SpecWith ByteString
spec Adapter
adapter =
String -> SpecWith ByteString -> SpecWith ByteString
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"paramtype" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"reports inferred parameter types" \ByteString
conninfo ->
Adapter
-> ByteString -> (Connection -> IO (Maybe [Word32])) -> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
_ <- Connection
-> ByteString -> ByteString -> Maybe [Word32] -> IO (Maybe Result)
Pqi.prepare Connection
connection ByteString
"conformance_paramtype" ByteString
"select $1 :: int4, $2 :: text" Maybe [Word32]
forall a. Maybe a
Nothing
described <- Pqi.describePrepared connection "conformance_paramtype"
for described \Result
r -> do
n <- Result -> IO Int32
Pqi.nparams Result
r
traverse (Pqi.paramtype r) [0 .. n - 1]
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"reports explicitly requested parameter types" \ByteString
conninfo ->
Adapter
-> ByteString -> (Connection -> IO (Maybe [Word32])) -> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
_ <- Connection
-> ByteString -> ByteString -> Maybe [Word32] -> IO (Maybe Result)
Pqi.prepare Connection
connection ByteString
"conformance_paramtype_typed" ByteString
"select $1" ([Word32] -> Maybe [Word32]
forall a. a -> Maybe a
Just [Word32
int8Oid])
described <- Pqi.describePrepared connection "conformance_paramtype_typed"
for described \Result
r -> do
n <- Result -> IO Int32
Pqi.nparams Result
r
traverse (Pqi.paramtype r) [0 .. n - 1]