postgresql-tx-query (empty) → 0.1.0.0
raw patch · 6 files changed
+195/−0 lines, 6 filesdep +basedep +monad-loggerdep +mtl
Dependencies added: base, monad-logger, mtl, postgresql-query, postgresql-simple, postgresql-tx, postgresql-tx-monad-logger, transformers
Files
- CHANGELOG.md +5/−0
- LICENSE.md +30/−0
- package.yaml +32/−0
- postgresql-tx-query.cabal +50/−0
- src/Database/PostgreSQL/Tx/Query.hs +61/−0
- src/Database/PostgreSQL/Tx/Query/Internal/Reexport.hs +17/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Change log++## 0.1.0.0++Initial release
+ LICENSE.md view
@@ -0,0 +1,30 @@+Copyright SimSpace (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of SimSpace nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ package.yaml view
@@ -0,0 +1,32 @@+name: postgresql-tx-query+version: 0.1.0.0+github: "simspace/postgresql-tx/query"+license: BSD3+license-file: LICENSE.md+author: "Cary Robbins"+maintainer: "carymrobbins@gmail.com"+copyright: "2020 SimSpace"+synopsis: postgresql-tx interfacing for use with postgresql-query.+category: Database+description: Please see the README on GitHub at <https://github.com/simspace/postgresql-tx#readme>++extra-source-files:+- CHANGELOG.md+- LICENSE.md+- package.yaml++ghc-options:+ - -Wall++dependencies:+- base >= 4.7 && < 5+- monad-logger >= 0.3.32 && < 0.4+- mtl >= 2.2.2 && < 2.3+- postgresql-query >= 3.5.0 && < 3.6+- postgresql-simple >= 0.6.2 && < 0.7+- postgresql-tx >= 0.1.0.0 && < 0.2+- postgresql-tx-monad-logger >= 0.1.0.0 && < 0.2+- transformers >= 0.5.6.2 && < 0.6++library:+ source-dirs: src
+ postgresql-tx-query.cabal view
@@ -0,0 +1,50 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 6e3ca7ec1f2e454d1e99e74cb23491feeec03749caaa5915dd4ab56d4196f856++name: postgresql-tx-query+version: 0.1.0.0+synopsis: postgresql-tx interfacing for use with postgresql-query.+description: Please see the README on GitHub at <https://github.com/simspace/postgresql-tx#readme>+category: Database+homepage: https://github.com/simspace/postgresql-tx#readme+bug-reports: https://github.com/simspace/postgresql-tx/issues+author: Cary Robbins+maintainer: carymrobbins@gmail.com+copyright: 2020 SimSpace+license: BSD3+license-file: LICENSE.md+build-type: Simple+extra-source-files:+ CHANGELOG.md+ LICENSE.md+ package.yaml++source-repository head+ type: git+ location: https://github.com/simspace/postgresql-tx+ subdir: query++library+ exposed-modules:+ Database.PostgreSQL.Tx.Query+ Database.PostgreSQL.Tx.Query.Internal.Reexport+ other-modules:+ Paths_postgresql_tx_query+ hs-source-dirs:+ src+ ghc-options: -Wall+ build-depends:+ base >=4.7 && <5+ , monad-logger >=0.3.32 && <0.4+ , mtl >=2.2.2 && <2.3+ , postgresql-query >=3.5.0 && <3.6+ , postgresql-simple >=0.6.2 && <0.7+ , postgresql-tx >=0.1.0.0 && <0.2+ , postgresql-tx-monad-logger >=0.1.0.0 && <0.2+ , transformers >=0.5.6.2 && <0.6+ default-language: Haskell2010
+ src/Database/PostgreSQL/Tx/Query.hs view
@@ -0,0 +1,61 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE UndecidableInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Database.PostgreSQL.Tx.Query+ ( module Database.PostgreSQL.Tx.Query+ , module Database.PostgreSQL.Tx.Query.Internal.Reexport+ ) where++import Control.Monad.Logger (LoggingT, runLoggingT)+import Control.Monad.Trans (MonadTrans(lift))+import Data.Int (Int64)+import Database.PostgreSQL.Tx (Tx(TxEnv, tx), UnsafeTx(unsafeIOTx), TxM, unsafeRunTxM)+import Database.PostgreSQL.Tx.Query.Internal.Reexport+import qualified Database.PostgreSQL.Query as Query+import qualified Database.PostgreSQL.Simple as Simple+import qualified Database.PostgreSQL.Simple.Transaction as Simple+import qualified Database.PostgreSQL.Tx.MonadLogger++type PgQueryM = PgMonadT (LoggingT TxM)++type Logger = Database.PostgreSQL.Tx.MonadLogger.Logger++pgWithTransaction :: (Simple.Connection, Logger) -> TxM a -> IO a+pgWithTransaction = unsafeRunPgQueryTransaction Query.pgWithTransaction++pgWithTransactionMode :: Simple.TransactionMode -> (Simple.Connection, Logger) -> TxM a -> IO a+pgWithTransactionMode m = unsafeRunPgQueryTransaction (Query.pgWithTransactionMode m)++-- Re-export of 'Query.pgQuery'+pgQuery :: (ToSqlBuilder q, FromRow r) => q -> PgQueryM [r]+pgQuery = unsafeIOTx . Query.pgQuery++-- Re-export of 'Query.pgExecute'+pgExecute :: (ToSqlBuilder q) => q -> PgQueryM Int64+pgExecute = unsafeIOTx . Query.pgExecute++unsafePgQueryIOTx :: PgMonadT (LoggingT IO) a -> PgQueryM a+unsafePgQueryIOTx = unsafeIOTx++unsafeRunPgQueryTransaction+ :: (PgMonadT (LoggingT IO) a -> PgMonadT (LoggingT IO) a)+ -> (Simple.Connection, Logger)+ -> TxM a+ -> IO a+unsafeRunPgQueryTransaction f (c, logger) x =+ unsafeRunTxM+ $ tx (c, logger)+ $ unsafePgQueryIOTx+ $ f+ $ lift . lift+ $ unsafeRunTxM x++instance Tx PgQueryM where+ type TxEnv PgQueryM = (Simple.Connection, Logger)+ tx (conn, logger) x = runLoggingT (runPgMonadT conn x) logger++instance (UnsafeTx io t) => UnsafeTx (PgMonadT io) (PgMonadT t) where+ unsafeIOTx (PgMonadT x) = PgMonadT $ unsafeIOTx x
+ src/Database/PostgreSQL/Tx/Query/Internal/Reexport.hs view
@@ -0,0 +1,17 @@+module Database.PostgreSQL.Tx.Query.Internal.Reexport+ ( module X+ ) where++import Database.PostgreSQL.Simple.Transaction as X+ ( defaultTransactionMode+ , TransactionMode(..)+ , IsolationLevel(..)+ , ReadWriteMode(..)+ )+-- Don't re-export names that we define in 'Database.PostgreSQL.Tx.Query'.+import Database.PostgreSQL.Query as X hiding+ ( pgWithTransaction+ , pgWithTransactionMode+ , pgQuery+ , pgExecute+ )