module Pqi.Conformance.Operation.Ntuples
( spec,
)
where
import qualified Pqi
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
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
"ntuples" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"counts rows across result shapes" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection -> IO (Maybe Int32, Maybe Int32, Maybe Int32))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
let countOf :: ByteString -> IO (Maybe Int32)
countOf ByteString
sql = Connection -> ByteString -> IO (Maybe Result)
Pqi.exec Connection
connection ByteString
sql IO (Maybe Result)
-> (Maybe Result -> IO (Maybe Int32)) -> IO (Maybe Int32)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Result -> IO Int32) -> Maybe Result -> IO (Maybe Int32)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse Result -> IO Int32
Pqi.ntuples
many <- ByteString -> IO (Maybe Int32)
countOf ByteString
"select i from generate_series (1, 3) as i"
none <- countOf "select 1 where false"
command <- countOf "create temporary table conformance_ntuples (id int4)"
pure (many, none, command)