hpqtypes-extras 1.16.4.3 → 1.16.4.4
raw patch · 4 files changed
+15/−14 lines, 4 filesdep +cryptondep +memorydep −cryptohashPVP ok
version bump matches the API change (PVP)
Dependencies added: crypton, memory
Dependencies removed: cryptohash
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- hpqtypes-extras.cabal +4/−3
- src/Database/PostgreSQL/PQTypes/Model/Index.hs +5/−3
- src/Database/PostgreSQL/PQTypes/SQL/Builder.hs +1/−8
CHANGELOG.md view
@@ -1,3 +1,8 @@+# hpqtypes-extras-1.16.4.4 (2023-08-23)+* Switch from `cryptonite` to `crypton`.+* Make `sqlWhereEqualsAny`, `sqlWhereIn` and `sqlWhereNotIn` prepared-query+ friendly.+ # hpqtypes-extras-1.16.4.3 (2023-06-12) * Synchronize timezone of a session with timezone of a database after changing the latter.
hpqtypes-extras.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: hpqtypes-extras-version: 1.16.4.3+version: 1.16.4.4 synopsis: Extra utilities for hpqtypes library description: The following extras for hpqtypes library: .@@ -20,7 +20,7 @@ copyright: Scrive AB category: Database build-type: Simple-tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.4 || ==9.6.1+tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.6 || ==9.6.2 Source-repository head Type: git@@ -80,9 +80,10 @@ , base16-bytestring >= 0.1 , bytestring >= 0.10 , containers >= 0.5- , cryptohash >= 0.11+ , crypton >= 0.32 , exceptions >= 0.10 , extra >= 1.6.17+ , memory >= 0.18 , mtl >= 2.2 , text >= 1.2 , text-show >= 3.7
src/Database/PostgreSQL/PQTypes/Model/Index.hs view
@@ -19,13 +19,14 @@ , sqlDropIndexConcurrently ) where -import Crypto.Hash.RIPEMD160-import Data.ByteString.Base16 import Data.Char import Data.Function import Data.String import Data.Monoid.Utils import Database.PostgreSQL.PQTypes+import qualified Crypto.Hash as H+import qualified Data.ByteArray as BA+import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Char8 as BS import qualified Data.Text as T import qualified Data.Text.Encoding as T@@ -166,7 +167,8 @@ _ -> '$' : acc -- hash WHERE clause and add it to index name so that indexes -- with the same columns, but different constraints can coexist- hashWhere = asText $ T.decodeUtf8 . encode . BS.take 10 . hash . T.encodeUtf8+ hashWhere = asText $ T.decodeUtf8 . B16.encode . BS.take 10+ . BA.convert . H.hash @_ @H.RIPEMD160 . T.encodeUtf8 -- | Create an index. Warning: if the affected table is large, this will prevent -- the table from being modified during the creation. If this is not acceptable,
src/Database/PostgreSQL/PQTypes/SQL/Builder.hs view
@@ -602,14 +602,9 @@ -- | Similar to 'sqlWhereIn', but uses @ANY@ instead of @SELECT UNNEST@. sqlWhereEqualsAny :: (MonadState v m, SqlWhere v, Show a, ToSQL a) => SQL -> [a] -> m ()-sqlWhereEqualsAny name = \case- [] -> sqlWhere "FALSE"- [value] -> sqlWhereEq name value- values -> sqlWhere $ name <+> "= ANY(" <?> Array1 values <+> ")"+sqlWhereEqualsAny name values = sqlWhere $ name <+> "= ANY(" <?> Array1 values <+> ")" sqlWhereIn :: (MonadState v m, SqlWhere v, Show a, ToSQL a) => SQL -> [a] -> m ()-sqlWhereIn _name [] = sqlWhere "FALSE"-sqlWhereIn name [value] = sqlWhereEq name value sqlWhereIn name values = do -- Unpack the array to give query optimizer more options. sqlWhere $ name <+> "IN (SELECT UNNEST(" <?> Array1 values <+> "))"@@ -618,8 +613,6 @@ sqlWhereInSql name sql = sqlWhere $ name <+> "IN" <+> parenthesize (toSQLCommand sql) sqlWhereNotIn :: (MonadState v m, SqlWhere v, Show a, ToSQL a) => SQL -> [a] -> m ()-sqlWhereNotIn _name [] = sqlWhere "TRUE"-sqlWhereNotIn name [value] = sqlWhereNotEq name value sqlWhereNotIn name values = sqlWhere $ name <+> "NOT IN (SELECT UNNEST(" <?> Array1 values <+> "))" sqlWhereNotInSql :: (MonadState v m, Sqlable a, SqlWhere v) => SQL -> a -> m ()