packages feed

hasql-dynamic-statements 0.5.0.1 → 0.5.1

raw patch · 2 files changed

+11/−4 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hasql.DynamicStatements.Snippet: toPreparableStatement :: Snippet -> Result result -> Statement () result

Files

hasql-dynamic-statements.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: hasql-dynamic-statements-version: 0.5.0.1+version: 0.5.1 synopsis: Hasql extension for dynamic construction of statements description:   Library extending Hasql with a composable API for building SQL statements dynamically.
src/library/Hasql/DynamicStatements/Snippet.hs view
@@ -4,6 +4,7 @@     -- * Execution     toSql,     toStatement,+    toPreparableStatement,     toSession,     toPipeline, @@ -127,14 +128,20 @@ --     foldMap (\\ x -> Encoders.'Encoders.param' (x '>$' Encoders.'Encoders.int8')) from '<>' --     foldMap (\\ x -> Encoders.'Encoders.param' (x '>$' Encoders.'Encoders.int8')) to --   decoder = Decoders.'Decoders.singleRow' (Decoders.'Decoders.column' (Decoders.'Decoders.nonNullable' Decoders.'Decoders.text'))---   in Statement.'Statement.preparable' sql encoder decoder+--   in Statement.'Statement.unpreparable' sql encoder decoder -- @ -- -- As you can see, the Snippet API abstracts over placeholders and -- matching encoder generation, thus also protecting you from all sorts of related bugs. toStatement :: Snippet -> Decoders.Result result -> Statement.Statement () result-toStatement (Snippet sql _ encoder) =-  Statement.unpreparable (TextBuilder.toText (sql 1)) encoder+toStatement = toStatement' Statement.unpreparable++toPreparableStatement :: Snippet -> Decoders.Result result -> Statement.Statement () result+toPreparableStatement = toStatement' Statement.preparable++toStatement' :: (Text -> Encoders.Params () -> t) -> Snippet -> t+toStatement' stmt (Snippet sql _ encoder) =+  stmt (TextBuilder.toText (sql 1)) encoder  -- | -- Execute in @Session.Session@, providing a result decoder.