postgresql-simple-named 0.0.4.0 → 0.0.5.0
raw patch · 4 files changed
+30/−19 lines, 4 filesdep ~basedep ~bytestringdep ~postgresql-simplePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, bytestring, postgresql-simple, resource-pool, text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−1
- postgresql-simple-named.cabal +13/−12
- src/PgNamed.hs +4/−4
- test/Spec.hs +8/−2
CHANGELOG.md view
@@ -3,6 +3,10 @@ `postgresql-simple-named` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.0.5.0 - Jan 4, 2024++* Add support for GHC 9.6 and 9.8+ ## 0.0.4.0 - Nov 2, 2022 * Add support for GHC 9.2 and 9.4@@ -11,7 +15,7 @@ * Add support for GHC 8.10 and 9.0 * [#30](https://github.com/Holmusk/postgresql-simple-named/issues/30):- Fixes a bug with postgres-simple-named not recognising postgres JSON operators + Fixes a bug with postgres-simple-named not recognising postgres JSON operators ## 0.0.2.0 — Sep 10, 2019
postgresql-simple-named.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: postgresql-simple-named-version: 0.0.4.0+version: 0.0.5.0 synopsis: Implementation of named parameters for `postgresql-simple` library description: Implementation of named parameters for @postgresql-simple@ library.@@ -27,18 +27,19 @@ category: Database, PostgreSQL build-type: Simple extra-source-files: README.md- , CHANGELOG.md-tested-with: GHC == 8.10.7- , GHC == 9.0.2- , GHC == 9.2.4- , GHC == 9.4.2+extra-doc-files: CHANGELOG.md+tested-with: GHC == 9.0.2+ , GHC == 9.2.8+ , GHC == 9.4.8+ , GHC == 9.6.3+ , GHC == 9.8.1 source-repository head type: git location: https://github.com/Holmusk/postgresql-simple-named.git common common-options- build-depends: base >= 4.11 && < 4.18+ build-depends: base >= 4.11 && < 4.20 ghc-options: -Wall -Wincomplete-uni-patterns@@ -73,10 +74,10 @@ import: common-options hs-source-dirs: src exposed-modules: PgNamed- build-depends: bytestring >= 0.10 && < 0.12+ build-depends: bytestring >= 0.10 && < 0.13 , mtl >= 2.2 && < 2.4- , postgresql-simple >= 0.5 && < 0.7- , text >= 1.2 && < 2.1+ , postgresql-simple >= 0.5 && < 0.8+ , text >= 1.2 && < 2.2 test-suite postgresql-simple-named-test import: common-options@@ -87,8 +88,8 @@ build-depends: bytestring , hspec >= 2.5 , postgresql-simple-named- , postgresql-simple >= 0.5 && < 0.7- , resource-pool ^>= 0.2.3.2+ , postgresql-simple >= 0.5 && < 0.8+ , resource-pool ^>= 0.2.3.2 || ^>= 0.4.0.0 , transformers ghc-options: -threaded -rtsopts -with-rtsopts=-N
src/PgNamed.hs view
@@ -210,7 +210,7 @@ and expects a list of rows in return. Sometimes there are multiple ways to parse tuples returned by PostgreSQL into-the same data type. However, it's not possible to implement multiple intances of+the same data type. However, it's not possible to implement multiple instances of the 'PG.FromRow' typeclass (or any other typeclass). Consider the following data type:@@ -224,11 +224,11 @@ We might want to parse values of the @Person@ data type in two ways: -1. Default by parsing all fields.+1. Default to parsing all fields. 2. Parse only name and @age@ to 'Nothing'. If you want to have multiple instances, you need to create @newtype@ for each-case. However, in some cases it might not be convenient to deal with newtypes+case. However, in some cases it might not be convenient to deal with @newtypes@ around large data types. So you can implement custom 'PG.RowParser' and use it with 'queryWithNamed'. @@ -272,7 +272,7 @@ withNamedArgs qNamed params >>= \(q, actions) -> liftIO $ PG.execute conn q (toList actions) -{- | Same as 'executeNamed' but discard the nubmer of rows affected by the given+{- | Same as 'executeNamed' but discard the number of rows affected by the given query. This function is useful when you're not interested in this number. -} executeNamed_
test/Spec.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE CPP #-} module Main (main) where @@ -25,7 +26,12 @@ main = do hSetEncoding stdout utf8 hSetEncoding stderr utf8- dbPool <- Pool.createPool (Sql.connectPostgreSQL connectionSettings) Sql.close 10 5 10+ dbPool <- +#if MIN_VERSION_resource_pool(0,4,0)+ Pool.newPool (Pool.defaultPoolConfig ((Sql.connectPostgreSQL connectionSettings)) Sql.close 1 10)+#else+ Pool.createPool (Sql.connectPostgreSQL connectionSettings) Sql.close 10 5 10+#endif hspec $ unitTests dbPool unitTests :: Pool.Pool Sql.Connection -> Spec@@ -77,7 +83,7 @@ -> Sql.Query -> [NamedParam] -> IO (Either PgNamedError TestValue)- callQuery f q params = runNamedQuery $ Pool.withResource dbPool (\conn -> f conn q params)+ callQuery f q params = Pool.withResource dbPool (\conn -> runNamedQuery $ f conn q params) runNamedQuery :: ExceptT PgNamedError IO [TestValue] -> IO (Either PgNamedError TestValue) runNamedQuery = fmap (second head) . runExceptT