diff --git a/library/Hasql/Decoders.hs b/library/Hasql/Decoders.hs index a031ef5..fa5c98d 100644 --- a/library/Hasql/Decoders.hs +++ b/library/Hasql/Decoders.hs @@ -5,7 +5,7 @@ module Hasql.Decoders ( -- * Result Result, - unit, + noResult, rowsAffected, singleRow, -- ** Specialized multi-row results diff --git a/library/Hasql/Private/Decoders.hs b/library/Hasql/Private/Decoders.hs index 4457bec..9a53888 100644 --- a/library/Hasql/Private/Decoders.hs +++ b/library/Hasql/Private/Decoders.hs @@ -29,9 +29,9 @@ Decode no value from the result. Useful for statements like @INSERT@ or @CREATE@. -} -{-# INLINABLE unit #-} -unit :: Result () -unit = Result (Results.single Result.unit) +{-# INLINABLE noResult #-} +noResult :: Result () +noResult = Result (Results.single Result.noResult) {-| Get the amount of rows affected by such statements as diff --git a/library/Hasql/Private/Decoders/Result.hs b/library/Hasql/Private/Decoders/Result.hs index 519a1b9..11acf77 100644 --- a/library/Hasql/Private/Decoders/Result.hs +++ b/library/Hasql/Private/Decoders/Result.hs @@ -20,9 +20,9 @@ run :: Result a -> (Bool, LibPQ.Result) -> IO (Either ResultError a) run (Result reader) env = runExceptT (runReaderT reader env) -{-# INLINE unit #-} -unit :: Result () -unit = +{-# INLINE noResult #-} +noResult :: Result () +noResult = checkExecStatus $ \case LibPQ.CommandOk -> True LibPQ.TuplesOk -> True diff --git a/library/Hasql/Private/Decoders/Results.hs b/library/Hasql/Private/Decoders/Results.hs index 34e8257..cf0cb56 100644 --- a/library/Hasql/Private/Decoders/Results.hs +++ b/library/Hasql/Private/Decoders/Results.hs @@ -81,4 +81,4 @@ dropRemainders = loop integerDatetimes connection <* checkErrors where checkErrors = - ExceptT $ fmap (mapLeft ResultError) $ Result.run Result.unit (integerDatetimes, result) + ExceptT $ fmap (mapLeft ResultError) $ Result.run Result.noResult (integerDatetimes, result) diff --git a/library/Hasql/Private/IO.hs b/library/Hasql/Private/IO.hs index f227a16..d51c712 100644 --- a/library/Hasql/Private/IO.hs +++ b/library/Hasql/Private/IO.hs @@ -88,7 +88,7 @@ getPreparedStatementKey connection registry template oidList = sent <- LibPQ.sendPrepare connection key template (mfilter (not . null) (Just oidList)) let resultsDecoder = if sent - then ResultsDecoders.single ResultDecoders.unit + then ResultsDecoders.single ResultDecoders.noResult else ResultsDecoders.clientError fmap resultsMapping $ getResults connection undefined resultsDecoder where diff --git a/library/Hasql/Private/Session.hs b/library/Hasql/Private/Session.hs index 4145b3b..d9dafb2 100644 --- a/library/Hasql/Private/Session.hs +++ b/library/Hasql/Private/Session.hs @@ -40,7 +40,7 @@ sql sql = return $ r1 *> r2 where decoder = - Decoders.Results.single Decoders.Result.unit + Decoders.Results.single Decoders.Result.noResult -- | -- Parameters and a specification of a parametric single-statement query to apply them to. diff --git a/library/Hasql/Statement.hs b/library/Hasql/Statement.hs index e5faf42..e60488b 100644 --- a/library/Hasql/Statement.hs +++ b/library/Hasql/Statement.hs @@ -25,7 +25,7 @@ module Hasql.Statement -- Encoders.'Encoders.foldableDimension' . -- Encoders.'Encoders.element' . -- Encoders.'Encoders.nonNullable' - -- decoder = Decoders.'Decoders.unit' + -- decoder = Decoders.'Decoders.noResult' -- @ -- -- This approach is much more efficient than executing a single-row Insert diff --git a/tasty/Main.hs b/tasty/Main.hs index 25dfaa0..c7772ca 100644 --- a/tasty/Main.hs +++ b/tasty/Main.hs @@ -184,7 +184,7 @@ tree = encoder = mempty decoder = - Decoders.unit + Decoders.noResult in io , testCase "Prepared statements after error" $ @@ -319,14 +319,14 @@ tree = DSL.session $ do let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "drop type if exists mood" in DSL.statement () statement let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "create type mood as enum ('sad', 'ok', 'happy')" @@ -350,14 +350,14 @@ tree = DSL.session $ do let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "create or replace function overloaded(a int, b int) returns int as $$ select a + b $$ language sql;" in DSL.statement () statement let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "create or replace function overloaded(a text, b text, c text) returns text as $$ select a || b || c $$ language sql;" @@ -381,14 +381,14 @@ tree = DSL.session $ do let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "drop type if exists mood" in DSL.statement () statement let statement = - Statement.Statement sql mempty Decoders.unit True + Statement.Statement sql mempty Decoders.noResult True where sql = "create type mood as enum ('sad', 'ok', 'happy')" diff --git a/tasty/Main/Statements.hs b/tasty/Main/Statements.hs index f67a4e3..ea3cbcc 100644 --- a/tasty/Main/Statements.hs +++ b/tasty/Main/Statements.hs @@ -9,7 +9,7 @@ import qualified Main.Prelude as Prelude plain :: ByteString -> HQ.Statement () () plain sql = - HQ.Statement sql mempty HD.unit False + HQ.Statement sql mempty HD.noResult False dropType :: ByteString -> HQ.Statement () () dropType name = diff --git a/threads-test/Main/Statements.hs b/threads-test/Main/Statements.hs index c6ebd19..a2f53d5 100644 --- a/threads-test/Main/Statements.hs +++ b/threads-test/Main/Statements.hs @@ -15,6 +15,6 @@ selectSleep = encoder = E.param (E.nonNullable E.float8) decoder = - D.unit + D.noResult