packages feed

esqueleto 3.4.0.1 → 3.4.1.0

raw patch · 5 files changed

+27/−18 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Database.Esqueleto.Internal.Internal: valueToRawSqlParens :: UnexpectedValueError -> SqlExpr (Value a) -> IdentInfo -> (Builder, [PersistValue])

Files

changelog.md view
@@ -1,3 +1,12 @@+3.4.1.0+=======+- @arthurxavierx+  - [#238](https://github.com/bitemyapp/esqueleto/pull/238)+    - Fix non-exhaustive patterns in `unsafeSqlAggregateFunction`+- @Vlix+  - [#232](https://github.com/bitemyapp/esqueleto/pull/232)+    - Export the `ValidOnClauseValue` type family+ 3.4.0.1 ======= - @arthurxavierx
esqueleto.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12  name:           esqueleto-version:        3.4.0.1+version:        3.4.1.0 synopsis:       Type-safe EDSL for SQL queries on persistent backends. description:    @esqueleto@ is a bare bones, type-safe EDSL for SQL queries that works with unmodified @persistent@ SQL backends.  Its language closely resembles SQL, so you don't have to learn new concepts, just new syntax, and it's fairly easy to predict the generated SQL and optimize it for your backend. Most kinds of errors committed when writing SQL are caught as compile-time errors---although it is possible to write type-checked @esqueleto@ queries that fail at runtime.                 .
src/Database/Esqueleto/Experimental.hs view
@@ -57,6 +57,7 @@     , ToAliasT     , ToAliasReference(..)     , ToAliasReferenceT+    , ValidOnClauseValue     -- * The Normal Stuff      , where_
src/Database/Esqueleto/Internal/Internal.hs view
@@ -2160,7 +2160,7 @@   where     buildCase :: IdentInfo -> (TLB.Builder, [PersistValue])     buildCase info =-        let (elseText, elseVals) = valueToSql v info+        let (elseText, elseVals) = valueToRawSqlParens SqlCaseError v info             (whenText, whenVals) = mapWhen when info         in ( "CASE" <> whenText <> " ELSE " <> elseText <> " END", whenVals <> elseVals) @@ -2172,15 +2172,20 @@     foldHelp _ _ (ECompositeKey _, _) = throw (CompositeKeyErr FoldHelpError)     foldHelp _ _ (_, ECompositeKey _) = throw (CompositeKeyErr FoldHelpError)     foldHelp info (b0, vals0) (v1, v2) =-        let (b1, vals1) = valueToSql v1 info-            (b2, vals2) = valueToSql v2 info+        let (b1, vals1) = valueToRawSqlParens SqlCaseError v1 info+            (b2, vals2) = valueToRawSqlParens SqlCaseError v2 info         in ( b0 <> " WHEN " <> b1 <> " THEN " <> b2, vals0 <> vals1 <> vals2 ) -    valueToSql :: SqlExpr (Value a) -> IdentInfo -> (TLB.Builder, [PersistValue])-    valueToSql (ERaw p f) = (first (parensM p)) . f-    valueToSql (ECompositeKey _) = throw (CompositeKeyErr SqlCaseError)-    valueToSql (EAliasedValue i _) = aliasedValueIdentToRawSql i-    valueToSql (EValueReference i i') = valueReferenceToRawSql i i'+-- | (Internal) Convert a value to a raw SQL builder, preserving parens around+-- 'ERaw' SQL expressions. This is useful for turning values into function or+-- operator arguments.+--+-- Since: 3.4.0.2+valueToRawSqlParens :: UnexpectedValueError -> SqlExpr (Value a) -> IdentInfo -> (TLB.Builder, [PersistValue])+valueToRawSqlParens _ (ERaw p f) = (first (parensM p)) . f+valueToRawSqlParens e (ECompositeKey _) = throw (CompositeKeyErr e)+valueToRawSqlParens _ (EAliasedValue i _) = aliasedValueIdentToRawSql i+valueToRawSqlParens _ (EValueReference i i') = valueReferenceToRawSql i i'  -- | (Internal) Create a custom binary operator.  You /should/ -- /not/ use this function directly since its type is very@@ -2323,14 +2328,8 @@     => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlFunctionParens name arg =     ERaw Never $ \info ->-        let valueToFunctionArgParens v =-                case v of-                    ERaw p f             -> first (parensM p) (f info)-                    EAliasedValue i _    -> aliasedValueIdentToRawSql i info-                    EValueReference i i' -> valueReferenceToRawSql i i' info-                    ECompositeKey _      -> throw (CompositeKeyErr SqlFunctionError)-            (argsTLB, argsVals) =-                uncommas' $ map valueToFunctionArgParens $ toArgList arg+        let (argsTLB, argsVals) =+                uncommas' $ map (\v -> valueToRawSqlParens SqlFunctionError v info) $ toArgList arg         in             (name <> parens argsTLB, argsVals) 
src/Database/Esqueleto/PostgreSQL.hs view
@@ -91,7 +91,7 @@                 [] -> ""                 (_:_) -> " "         (argsTLB, argsVals) =-            uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList args+            uncommas' $ map (\v -> valueToRawSqlParens SqlFunctionError v info) $ toArgList args         aggMode =             case mode of                 AggModeAll -> ""