From 9f6f9b325c8d9a3b0de708f6e7e40e157a655c33 Mon Sep 17 00:00:00 2001 From: belevy Date: Sun, 29 Nov 2020 19:50:42 -0600 Subject: [PATCH] Cleanup hackage documentation. Make sure stylish ran correctly. Update changelog and bump version --- changelog.md | 6 +++ esqueleto.cabal | 2 +- src/Database/Esqueleto/Experimental.hs | 39 ++++++++++++++++++- src/Database/Esqueleto/Experimental/From.hs | 4 +- .../Esqueleto/Experimental/From/Join.hs | 3 +- .../Experimental/From/SqlSetOperation.hs | 33 ---------------- 6 files changed, 47 insertions(+), 40 deletions(-) diff --git a/changelog.md b/changelog.md index 40a3137..63664e4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +3.4.1.0 +======= +- @belevy + - [#228](https://github.com/bitemyapp/esqueleto/pull/228) + - Remove From GADT in favor of From typeclass. + 3.4.0.1 ======= - @arthurxavierx diff --git a/esqueleto.cabal b/esqueleto.cabal index 59d6b8f..631bffd 100644 --- a/esqueleto.cabal +++ b/esqueleto.cabal @@ -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. . diff --git a/src/Database/Esqueleto/Experimental.hs b/src/Database/Esqueleto/Experimental.hs index 154c06b..8466b04 100644 --- a/src/Database/Esqueleto/Experimental.hs +++ b/src/Database/Esqueleto/Experimental.hs @@ -19,10 +19,10 @@ module Database.Esqueleto.Experimental -- * Documentation Table(..) - , on , from , SubQuery(..) , (:&)(..) + , on -- ** Set Operations -- $sql-set-operations @@ -47,6 +47,7 @@ module Database.Esqueleto.Experimental , ToAliasT , ToAliasReference(..) , ToAliasReferenceT + , ToSetOperation(..) -- * The Normal Stuff , where_ @@ -207,8 +208,8 @@ module Database.Esqueleto.Experimental import Database.Esqueleto.Internal.Internal hiding (From, from, on) import Database.Esqueleto.Internal.PersistentImport -import Database.Esqueleto.Experimental.From.CommonTableExpression import Database.Esqueleto.Experimental.From +import Database.Esqueleto.Experimental.From.CommonTableExpression import Database.Esqueleto.Experimental.From.Join import Database.Esqueleto.Experimental.From.SqlSetOperation import Database.Esqueleto.Experimental.ToAlias @@ -511,3 +512,37 @@ import Database.Esqueleto.Experimental.ToMaybe -- max_sale.amount) -- AS max_sale_customer; -- @ + +-- $sql-set-operations +-- +-- Data type that represents SQL set operations. This includes +-- 'UNION', 'UNION' 'ALL', 'EXCEPT', and 'INTERSECT'. These types form +-- a binary tree, with @SqlQuery@ values on the leaves. +-- +-- Each function corresponding to the aforementioned set operations +-- can be used as an infix in a @from@ to help with readability +-- and lead to code that closely resembles the underlying SQL. For example, +-- +-- @ +-- select $ from $ +-- (do +-- a <- from Table @A +-- pure $ a ^. ASomeCol +-- ) +-- \`union_\` +-- (do +-- b <- from Table @B +-- pure $ b ^. BSomeCol +-- ) +-- @ +-- +-- is translated into +-- +-- @ +-- SELECT * FROM ( +-- (SELECT a.some_col FROM a) +-- UNION +-- (SELECT b.some_col FROM b) +-- ) +-- @ +-- diff --git a/src/Database/Esqueleto/Experimental/From.hs b/src/Database/Esqueleto/Experimental/From.hs index bf51b01..085ff9d 100644 --- a/src/Database/Esqueleto/Experimental/From.hs +++ b/src/Database/Esqueleto/Experimental/From.hs @@ -16,10 +16,10 @@ module Database.Esqueleto.Experimental.From import qualified Control.Monad.Trans.Writer as W import Data.Proxy -import Database.Esqueleto.Internal.Internal hiding (From(..), from, on) -import Database.Esqueleto.Internal.PersistentImport import Database.Esqueleto.Experimental.ToAlias import Database.Esqueleto.Experimental.ToAliasReference +import Database.Esqueleto.Internal.Internal hiding (From(..), from, on) +import Database.Esqueleto.Internal.PersistentImport -- | 'FROM' clause, used to bring entities into scope. -- diff --git a/src/Database/Esqueleto/Experimental/From/Join.hs b/src/Database/Esqueleto/Experimental/From/Join.hs index b2d39a4..a5f520e 100644 --- a/src/Database/Esqueleto/Experimental/From/Join.hs +++ b/src/Database/Esqueleto/Experimental/From/Join.hs @@ -71,8 +71,7 @@ type family ErrorOnLateral a :: Constraint where ErrorOnLateral (a -> SqlQuery b) = TypeError ('Text "LATERAL can only be used for INNER, LEFT, and CROSS join kinds.") ErrorOnLateral _ = () -{-- Type class magic to allow the use of the `InnerJoin` family of data constructors in from --} - +-- Type class magic to allow the use of the `InnerJoin` family of data constructors in from type family FromOnClause a where FromOnClause (a, b -> SqlExpr (Value Bool)) = b FromOnClause a = TypeError ('Text "Missing ON clause") diff --git a/src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs b/src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs index f3bd607..05df34f 100644 --- a/src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs +++ b/src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs @@ -84,39 +84,6 @@ runSetOperation operation = do (q2, v2) = operationToSql o2 info in (q1 <> " " <> operationText <> " " <> q2, v1 <> v2) --- $sql-set-operations --- --- Data type that represents SQL set operations. This includes --- 'UNION', 'UNION' 'ALL', 'EXCEPT', and 'INTERSECT'. These types form --- a binary tree, with @SqlQuery@ values on the leaves. --- --- Each function corresponding to the aforementioned set operations --- can be used as an infix in a @from@ to help with readability --- and lead to code that closely resembles the underlying SQL. For example, --- --- @ --- select $ from $ --- (do --- a <- from Table @A --- pure $ a ^. ASomeCol --- ) --- \`union_\` --- (do --- b <- from Table @B --- pure $ b ^. BSomeCol --- ) --- @ --- --- is translated into --- --- @ --- SELECT * FROM ( --- (SELECT a.some_col FROM a) --- UNION --- (SELECT b.some_col FROM b) --- ) --- @ --- {-# DEPRECATED Union "/Since: 3.4.0.0/ - Use the 'union_' function instead of the 'Union' data constructor" #-} data Union a b = a `Union` b