packages feed

postgresql-simple-named 0.0.2.0 → 0.0.3.0

raw patch · 6 files changed

+35/−14 lines, 6 filesdep ~basedep ~hspecdep ~postgresql-simplesetup-changednew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, hspec, postgresql-simple

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,6 +3,12 @@ `postgresql-simple-named` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.0.3.0 - Jun 1, 2022++* Adds 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 + ## 0.0.2.0 — Sep 10, 2019  * [#21](https://github.com/holmusk/postgresql-simple-named/issues/21):
README.md view
@@ -1,5 +1,7 @@ # postgresql-simple-named +![Logo](https://user-images.githubusercontent.com/4276606/68105647-408b7c00-fef0-11e9-8d70-d3fbf314a647.png)+ [![Build status](https://img.shields.io/travis/Holmusk/postgresql-simple-named.svg?logo=travis)](https://travis-ci.org/Holmusk/postgresql-simple-named) [![Hackage](https://img.shields.io/hackage/v/postgresql-simple-named.svg?logo=haskell)](https://hackage.haskell.org/package/postgresql-simple-named) [![Stackage Lts](http://stackage.org/package/postgresql-simple-named/badge/lts)](http://stackage.org/lts/package/postgresql-simple-named)@@ -73,8 +75,8 @@ ## How to test locally  * Run DB in a Docker in a separate terminal window using command:-  ```-  docker run -p 5432\:5432 -e POSTGRES_USER=postgres -e POSTGRES_DB=pg_named postgres\:10.5-alpine+  ```bash+  docker run -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:12   ``` * Run tests using `cabal new-test` or `stack test` 
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
postgresql-simple-named.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                postgresql-simple-named-version:             0.0.2.0+version:             0.0.3.0 synopsis:            Implementation of named parameters for `postgresql-simple` library description:     Implementation of named parameters for @postgresql-simple@ library.@@ -26,17 +26,18 @@ copyright:           2019 Holmusk category:            Database, PostgreSQL build-type:          Simple-extra-doc-files:     README.md+extra-source-files:  README.md                    , CHANGELOG.md-tested-with:         GHC == 8.4.4-                   , GHC == 8.6.5+tested-with:         GHC == 8.8.4+                   , GHC == 8.10.7+                   , GHC == 9.0.2  source-repository head   type:                git   location:            https://github.com/Holmusk/postgresql-simple-named.git  common common-options-  build-depends:       base >= 4.11 && < 4.13+  build-depends:       base >= 4.11 && < 4.16    ghc-options:         -Wall                        -Wincomplete-uni-patterns@@ -47,6 +48,10 @@                        -fhide-source-paths                        -Wmissing-export-lists                        -Wpartial-fields+  if impl(ghc >= 8.8)+    ghc-options:       -Wmissing-deriving-strategies+  if impl(ghc >= 8.10)+    ghc-options:       -Wunused-packages    default-language:    Haskell2010   default-extensions:  ConstraintKinds@@ -69,7 +74,7 @@   exposed-modules:     PgNamed   build-depends:       bytestring ^>= 0.10.8                      , mtl ^>= 2.2-                     , postgresql-simple ^>= 0.6.2+                     , postgresql-simple >= 0.5 && < 0.7                      , text ^>= 1.2  test-suite postgresql-simple-named-test@@ -79,9 +84,9 @@   main-is:             Spec.hs    build-depends:       bytestring-                     , hspec >= 2.6 && < 2.8+                     , hspec >= 2.5                      , postgresql-simple-named-                     , postgresql-simple+                     , postgresql-simple >= 0.5 && < 0.7                      , resource-pool ^>= 0.2.3.2                      , transformers 
src/PgNamed.hs view
@@ -51,7 +51,6 @@ import Data.ByteString (ByteString) import Data.Char (isAlphaNum) import Data.Int (Int64)-import Data.List (lookup) import Data.List.NonEmpty (NonEmpty (..), toList) import Data.Text (Text) import Data.Text.Encoding (decodeUtf8)@@ -60,6 +59,7 @@ import qualified Data.ByteString.Char8 as BS import qualified Database.PostgreSQL.Simple as PG import qualified Database.PostgreSQL.Simple.FromRow as PG+import qualified Database.PostgreSQL.Simple.Internal as PG import qualified Database.PostgreSQL.Simple.ToField as PG import qualified Database.PostgreSQL.Simple.Types as PG @@ -114,6 +114,13 @@  >>> extractNames "SELECT * FROM users WHERE foo = ?foo AND bar = ?bar AND baz = ?foo" Right ("SELECT * FROM users WHERE foo = ? AND bar = ? AND baz = ?","foo" :| ["bar","foo"])++>>> extractNames "SELECT foo FROM my_table WHERE (foo->'bar' ??| ?selectedTags);"+Right ("SELECT foo FROM my_table WHERE (foo->'bar' ?| ?);","selectedTags" :| [])++When the operator is not escaped, it's treated as a named parameter+>>> extractNames "SELECT foo FROM my_table WHERE (foo->'bar' ?| ?selectedTags);"+Left PostgreSQL named parameter error: Query contains an empty name: SELECT foo FROM my_table WHERE (foo->'bar' ?| ?selectedTags); -} extractNames     :: PG.Query@@ -125,7 +132,7 @@     go :: ByteString -> Either PgNamedError (ByteString, [Name])     go str         | BS.null str = Right ("", [])-        | otherwise   = let (before, after) = BS.break (== '?') str in+        | otherwise   = let (before, after) = PG.breakOnSingleQuestionMark str in             case BS.uncons after of                 Nothing -> Right (before, [])                 Just ('?', nameStart) ->@@ -138,7 +145,6 @@      isNameChar :: Char -> Bool     isNameChar c = isAlphaNum c || c == '_'-  {- | Returns the list of values to use in query by given list of 'Name's. Throws 'PgNamedError' if any named parameter is not specified.
test/Spec.hs view
@@ -19,7 +19,7 @@   connectionSettings :: ByteString-connectionSettings = "host=localhost port=5432 user=postgres dbname=pg_named"+connectionSettings = "host=localhost port=5432 user=postgres password=postgres dbname=postgres"  main :: IO () main = do