diff --git a/changelog.md b/changelog.md index b054153..49f3243 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +3.5.2.0 +======= +- @ivanbakel + - [#268](https://github.com/bitemyapp/esqueleto/pull/268) + - Added `SqlSelect` instance for `(:&)`, allowing it to be returned from + queries just like `(,)` tuples. + 3.5.1.0 ======= - @ibarrae diff --git a/esqueleto.cabal b/esqueleto.cabal index 49b567e..f192cbf 100644 --- a/esqueleto.cabal +++ b/esqueleto.cabal @@ -1,7 +1,7 @@ cabal-version: 1.12 name: esqueleto -version: 3.5.1.0 +version: 3.5.2.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/From/Join.hs b/src/Database/Esqueleto/Experimental/From/Join.hs index ee8c709..7559ca7 100644 --- a/src/Database/Esqueleto/Experimental/From/Join.hs +++ b/src/Database/Esqueleto/Experimental/From/Join.hs @@ -49,6 +49,18 @@ class ValidOnClause a instance {-# OVERLAPPABLE #-} ToFrom a a' => ValidOnClause a instance ValidOnClause (a -> SqlQuery b) +-- | You may return joined values from a 'select' query - this is +-- identical to the tuple instance, but is provided for convenience. +-- +-- @since 3.5.2.0 +instance (SqlSelect a ra, SqlSelect b rb) => SqlSelect (a :& b) (ra :& rb) where + sqlSelectCols esc (a :& b) = sqlSelectCols esc (a, b) + sqlSelectColCount = sqlSelectColCount . toTuple + where + toTuple :: Proxy (a :& b) -> Proxy (a, b) + toTuple = const Proxy + sqlSelectProcessRow = fmap (uncurry (:&)) . sqlSelectProcessRow + -- | An @ON@ clause that describes how two tables are related. This should be -- used as an infix operator after a 'JOIN'. For example, --