packages feed

esqueleto 2.2.7 → 2.2.8

raw patch · 4 files changed

+84/−1 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.Esqueleto.PostgreSQL: arrayAgg :: SqlExpr (Value a) -> SqlExpr (Value [a])
+ Database.Esqueleto.PostgreSQL: stringAgg :: IsString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s)

Files

esqueleto.cabal view
@@ -1,5 +1,5 @@ name:                esqueleto-version:             2.2.7+version:             2.2.8 synopsis:            Type-safe EDSL for SQL queries on persistent backends. homepage:            https://github.com/prowdsponsor/esqueleto license:             BSD3@@ -57,6 +57,7 @@ library   exposed-modules:     Database.Esqueleto+    Database.Esqueleto.PostgreSQL     Database.Esqueleto.Internal.Language     Database.Esqueleto.Internal.Sql   other-modules:
src/Database/Esqueleto.hs view
@@ -87,6 +87,9 @@   , (<#)   , (<&>) +    -- * RDBMS-specific modules+    -- $rdbmsSpecificModules+     -- * Helpers   , valkey   , valJ@@ -375,6 +378,22 @@ -- --  * Everything from "Database.Persist.Sql" except for --    @deleteWhereCount@ and @updateWhereCount@.+++----------------------------------------------------------------------+++-- $rdbmsSpecificModules+--+-- There are many differences between SQL syntax and functions+-- supported by different RDBMSs.  Since version 2.2.8,+-- @esqueleto@ includes modules containing functions that are+-- specific to a given RDBMS.+--+--  * PostgreSQL: "Database.Esqueleto.PostgreSQL".+--+-- In order to use these functions, you need to explicitly import+-- their corresponding modules, they're not re-exported here.   ----------------------------------------------------------------------
+ src/Database/Esqueleto/PostgreSQL.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE OverloadedStrings+ #-}+-- | This module contain PostgreSQL-specific functions.+--+-- /Since: 2.2.8/+module Database.Esqueleto.PostgreSQL+  ( arrayAgg+  , stringAgg+  ) where++import Data.String (IsString)++import Database.Esqueleto.Internal.Language+import Database.Esqueleto.Internal.Sql+++-- | (@array_agg@) Concatenate input values, including @NULL@s,+-- into an array.+--+-- /Since: 2.2.8/+arrayAgg :: SqlExpr (Value a) -> SqlExpr (Value [a])+arrayAgg = unsafeSqlFunction "array_agg"+++-- | (@string_agg@) Concatenate input values separated by a+-- delimiter.+--+-- /Since: 2.2.8/+stringAgg+  :: IsString s+  => SqlExpr (Value s) -- ^ Input values.+  -> SqlExpr (Value s) -- ^ Delimiter.+  -> SqlExpr (Value s) -- ^ Concatenation.+stringAgg expr delim = unsafeSqlFunction "string_agg" (expr, delim)
test/Test.hs view
@@ -53,6 +53,7 @@ import qualified Data.List as L import qualified Data.Set as S import qualified Data.Text.Lazy.Builder as TLB+import qualified Database.Esqueleto.PostgreSQL as EP import qualified Database.Esqueleto.Internal.Sql as EI  @@ -1312,6 +1313,34 @@       it "looks sane for ForUpdate"       $ sanityCheck ForUpdate       "FOR UPDATE"       it "looks sane for ForShare"        $ sanityCheck ForShare        "FOR SHARE"       it "looks sane for LockInShareMode" $ sanityCheck LockInShareMode "LOCK IN SHARE MODE"++    describe "PostgreSQL module" $ do+      it "should be tested on the PostgreSQL database" $+#if !defined(WITH_POSTGRESQL)+        pendingWith "test suite not running under PostgreSQL, skipping"+#else+        (return () :: IO ())++      it "arrayAgg looks sane" $+        run $ do+          let people = [p1, p2, p3, p4, p5]+          mapM_ insert people+          [Value ret] <-+            select $+            from $ \p -> do+            return (EP.arrayAgg (p ^. PersonName))+          liftIO $ L.sort ret `shouldBe` L.sort (map personName people)++      it "stringAgg looks sane" $+        run $ do+          let people = [p1, p2, p3, p4, p5]+          mapM_ insert people+          [Value ret] <-+            select $+            from $ \p -> do+            return (EP.stringAgg (p ^. PersonName) (val " "))+          liftIO $ L.sort (words ret) `shouldBe` L.sort (map personName people)+#endif   ----------------------------------------------------------------------