hasql 0.1.3 → 0.1.4
raw patch · 4 files changed
+18/−13 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hasql: instance Eq Error
+ Hasql: instance Ord Error
Files
- demo/Main.hs +6/−5
- hasql.cabal +5/−3
- library/Hasql.hs +6/−4
- library/Hasql/RowParser.hs +1/−1
demo/Main.hs view
@@ -48,11 +48,12 @@ H.tx (Just (H.Serializable, True)) $ do -- Use MaybeT to handle empty results: runMaybeT $ do- do- Identity balance1 <- MaybeT $ H.single $ [H.q|SELECT balance FROM a WHERE id=?|] id1- Identity balance2 <- MaybeT $ H.single $ [H.q|SELECT balance FROM a WHERE id=?|] id2- lift $ H.unit $ [H.q|UPDATE a SET balance=? WHERE id=?|] (balance1 - amount) id1- lift $ H.unit $ [H.q|UPDATE a SET balance=? WHERE id=?|] (balance2 + amount) id2+ -- To distinguish results rows containing just one column, + -- we use 'Identity' as a sort of a single element tuple.+ Identity balance1 <- MaybeT $ H.single $ [H.q|SELECT balance FROM a WHERE id=?|] id1+ Identity balance2 <- MaybeT $ H.single $ [H.q|SELECT balance FROM a WHERE id=?|] id2+ lift $ H.unit $ [H.q|UPDATE a SET balance=? WHERE id=?|] (balance1 - amount) id1+ lift $ H.unit $ [H.q|UPDATE a SET balance=? WHERE id=?|] (balance2 + amount) id2 -- Output all the updated rows: do
hasql.cabal view
@@ -1,7 +1,7 @@ name: hasql version:- 0.1.3+ 0.1.4 synopsis: A minimalistic general high level API for relational databases description:@@ -40,9 +40,11 @@ . Links: .- * <http://hackage.haskell.org/package/hasql-0.1.3/src/demo/Main.hs A basic tutorial-demo>+ * <http://nikita-volkov.github.io/hasql-benchmarks/ Benchmarks analysis>. .- * <http://hackage.haskell.org/package/hasql-postgres A PostgreSQL backend>+ * <http://hackage.haskell.org/package/hasql-0.1.3/src/demo/Main.hs A basic tutorial-demo>.+ .+ * <http://hackage.haskell.org/package/hasql-postgres A PostgreSQL backend>. . category: Database
library/Hasql.hs view
@@ -2,7 +2,7 @@ -- This is the API of the \"hasql\" library. -- For an introduction to the package -- and links to more documentation please refer to --- <index.html the package's index page>.+-- <../ the package's index page>. module Hasql ( -- * Session@@ -15,9 +15,11 @@ -- * Transaction Tx,+ tx,++ -- ** Transaction Settings Mode, Backend.IsolationLevel(..),- tx, -- * Statement Quasi-Quoter QQ.q,@@ -146,7 +148,7 @@ -- Attempt to parse a row into an incompatible type. -- Indicates either a mismatching schema or an incorrect query. UnparsableRow Text- deriving (Show, Typeable)+ deriving (Show, Typeable, Eq, Ord) instance Exception Error @@ -258,7 +260,7 @@ -- | -- Execute a @SELECT@ statement,--- and produce a vector of results.+-- and produce a list of results. list :: Backend b => RowParser b r => Backend.Statement b -> Tx b s [r] list s = Tx $ ReaderT $ \c -> do
library/Hasql/RowParser.hs view
@@ -26,7 +26,7 @@ InstanceD constraints head [parseRowDec] where varNames =- [1 .. arity] >>= \i -> return (mkName ('_' : show i))+ [1 .. arity] >>= \i -> return (mkName ('v' : show i)) varTypes = map VarT varNames backendType =