packages feed

esqueleto 3.5.7.0 → 3.5.7.1

raw patch · 4 files changed

+35/−18 lines, 4 filesdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: text

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,3 +1,9 @@+3.5.7.1+=======+- @belevy+    - [#334](https://github.com/bitemyapp/esqueleto/pull/334)+        - Fix alias name bug with union and subselect + 3.5.7.0 ======= - @ivanbakel@@ -6,7 +12,6 @@           by `deriveEsqueletoRecord`, allowing in-SQL records to be used in           CTEs -======= - @9999years     - [#324](https://github.com/bitemyapp/esqueleto/pull/324)         - Add ability to use nested records with `deriveEsqueletoRecord`
esqueleto.cabal view
@@ -2,7 +2,7 @@  name:           esqueleto -version:        3.5.7.0+version:        3.5.7.1 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/ToAlias.hs view
@@ -16,26 +16,20 @@     toAlias :: a -> SqlQuery a  instance ToAlias (SqlExpr (Value a)) where-    toAlias e@(ERaw m f)-      | Just _ <- sqlExprMetaAlias m = pure e-      | otherwise = do-            ident <- newIdentFor (DBName "v")-            pure $ ERaw noMeta{sqlExprMetaAlias = Just ident} f+    toAlias (ERaw m f) = do+        ident <- newIdentFor (DBName "v")+        pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f  instance ToAlias (SqlExpr (Entity a)) where-    toAlias e@(ERaw m f)-      | Just _ <- sqlExprMetaAlias m = pure e-      | otherwise = do-           ident <- newIdentFor (DBName "v")-           pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f+    toAlias (ERaw m f) = do+       ident <- newIdentFor (DBName "v")+       pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f  instance ToAlias (SqlExpr (Maybe (Entity a))) where     -- FIXME: Code duplication because the compiler doesnt like half final encoding-    toAlias e@(ERaw m f)-      | Just _ <- sqlExprMetaAlias m = pure e-      | otherwise = do-           ident <- newIdentFor (DBName "v")-           pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f+    toAlias (ERaw m f) = do+       ident <- newIdentFor (DBName "v")+       pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f  instance (ToAlias a, ToAlias b) => ToAlias (a,b) where     toAlias (a,b) = (,) <$> toAlias a <*> toAlias b
test/PostgreSQL/Test.hs view
@@ -41,7 +41,7 @@ import qualified Database.Esqueleto.PostgreSQL as EP import Database.Esqueleto.PostgreSQL.JSON hiding ((-.), (?.), (||.)) import qualified Database.Esqueleto.PostgreSQL.JSON as JSON-import Database.Persist.Postgresql (withPostgresqlConn, createPostgresqlPool)+import Database.Persist.Postgresql (createPostgresqlPool, withPostgresqlConn) import Database.PostgreSQL.Simple (ExecStatus(..), SqlError(..)) import System.Environment import Test.Hspec@@ -1318,6 +1318,23 @@                                        , (Value 2, Value "str2", Value $ Just 2.5)                                        , (Value 3, Value "str3", Value Nothing) ] +testSubselectUnionError :: SpecDb+testSubselectUnionError = do+    describe "Subselect union error" $ do+        itDb "doesnt erroneously repeat variable names when using subselect + union" $ do+            let lordQuery = do+                    l <- Experimental.from $ table @Lord+                    pure (l ^. LordCounty, l ^. LordDogs)+                personQuery = do+                    p <- Experimental.from $ table @Person+                    pure (p ^. PersonName, just $ p ^. PersonFavNum)+            _ <- select $+                Experimental.from $ do+                    (str, _) <- Experimental.from $ lordQuery `union_` personQuery+                    pure (str, val @Int 1)+            asserting noExceptions++ type JSONValue = Maybe (JSONB A.Value)  createSaneSQL :: (PersistField a, MonadIO m) => SqlExpr (Value a) -> T.Text -> [PersistValue] -> SqlPersistT m ()@@ -1411,6 +1428,7 @@                 testJSONOperators         testLateralQuery         testValuesExpression+        testSubselectUnionError  insertJsonValues :: SqlPersistT IO () insertJsonValues = do