packages feed

selda-postgresql 0.1.5.0 → 0.1.5.1

raw patch · 3 files changed

+44/−25 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

selda-postgresql.cabal view
@@ -1,5 +1,5 @@ name:                selda-postgresql-version:             0.1.5.0+version:             0.1.5.1 synopsis:            PostgreSQL backend for the Selda database EDSL. description:         PostgreSQL backend for the Selda database EDSL.                      Requires the PostgreSQL @libpq@ development libraries to be@@ -28,14 +28,14 @@     OverloadedStrings     CPP   build-depends:-      base             >=4.8     && <5-    , exceptions       >=0.8     && <0.9-    , selda            >=0.1.8.0 && <0.2-    , text             >=1.0     && <1.3+      base       >=4.8     && <5+    , bytestring >=0.9 && <0.11+    , exceptions >=0.8     && <0.9+    , selda      >=0.1.8.0 && <0.2+    , text       >=1.0     && <1.3   if !flag(haste)     build-depends:-        bytestring       >=0.9 && <0.11-      , postgresql-libpq >=0.9 && <0.10+      postgresql-libpq >=0.9 && <0.10   if impl(ghc < 7.11)     build-depends:       transformers  >=0.4 && <0.6
src/Database/Selda/PostgreSQL.hs view
@@ -6,6 +6,7 @@   , pgOpen, seldaClose   , pgConnString   ) where+import qualified Data.ByteString.Char8 as BS import Data.Dynamic import Data.Monoid import qualified Data.Text as T@@ -17,7 +18,6 @@ #ifndef __HASTE__ import Database.Selda.PostgreSQL.Encoding import Database.PostgreSQL.LibPQ hiding (user, pass, db, host)-import qualified Data.ByteString.Char8 as BS #endif  -- | PostgreSQL connection information.@@ -63,6 +63,26 @@   } infixl 4 `auth` +-- | Convert `PGConnectInfo` into `ByteString`+pgConnString :: PGConnectInfo -> BS.ByteString+#ifdef __HASTE__+pgConnString PGConnectInfo{..} = error "pgConnString called in JS context"+#else+pgConnString PGConnectInfo{..} = mconcat+  [ "host=", encodeUtf8 pgHost, " "+  , "port=", BS.pack (show pgPort), " "+  , "dbname=", encodeUtf8 pgDatabase, " "+  , case pgUsername of+      Just user -> "user=" <> encodeUtf8 user <> " "+      _         -> ""+  , case pgPassword of+      Just pass -> "password=" <> encodeUtf8 pass <> " "+      _         -> ""+  , "connect_timeout=10", " "+  , "client_encoding=UTF8"+  ]+#endif+ -- | Perform the given computation over a PostgreSQL database. --   The database connection is guaranteed to be closed when the computation --   terminates.@@ -74,11 +94,15 @@ withPostgreSQL ci m = do   c <- pgOpen ci   runSeldaT m c `finally` seldaClose c+#endif  -- | Open a new PostgreSQL connection. The connection will persist across --   calls to 'runSeldaT', and must be explicitly closed using 'seldaClose' --   when no longer needed. pgOpen :: (MonadIO m, MonadThrow m) => PGConnectInfo -> m SeldaConnection+#ifdef __HASTE__+pgOpen _ = return $ error "pgOpen called in JS context"+#else pgOpen ci = do   conn <- liftIO $ connectdb connstr   st <- liftIO $ status conn@@ -116,22 +140,6 @@     left _        = error "impossible"     right (Right x) = x     right _         = error "impossible"---- | Convert `PGConnectInfo` into `ByteString`-pgConnString :: PGConnectInfo -> BS.ByteString-pgConnString PGConnectInfo{..} = mconcat-  [ "host=", encodeUtf8 pgHost, " "-  , "port=", BS.pack (show pgPort), " "-  , "dbname=", encodeUtf8 pgDatabase, " "-  , case pgUsername of-      Just user -> "user=" <> encodeUtf8 user <> " "-      _         -> ""-  , case pgPassword of-      Just pass -> "password=" <> encodeUtf8 pass <> " "-      _         -> ""-  , "connect_timeout=10", " "-  , "client_encoding=UTF8"-  ]  pgQueryRunner :: Connection -> Bool -> T.Text -> [Param] -> IO (Either Int (Int, [[SqlValue]])) pgQueryRunner c return_lastid q ps = do
src/Database/Selda/PostgreSQL/Encoding.hs view
@@ -1,9 +1,19 @@-{-# LANGUAGE GADTs, BangPatterns, OverloadedStrings #-}+{-# LANGUAGE GADTs, BangPatterns, OverloadedStrings, CPP #-} -- | Encoding/decoding for PostgreSQL. module Database.Selda.PostgreSQL.Encoding   ( toSqlValue, fromSqlValue, fromSqlType   , readInt   ) where+#ifdef __HASTE__++toSqlValue, fromSqlValue, fromSqlType, readInt :: a+toSqlValue = undefined+fromSqlValue = undefined+fromSqlType = undefined+readInt = undefined++#else+ import Control.Exception (throw) import qualified Data.ByteString as BS import Data.ByteString.Builder@@ -112,3 +122,4 @@   case LBS.toChunks bs of     [bs'] -> bs'     bss   -> BS.concat bss+#endif