Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update esqueleto-next #392

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
--health-retries=3
strategy:
matrix:
cabal: ["3.6"]
ghc: ["8.6.5", "8.8.4", "8.10.4", "9.0.2", "9.2.2"]
cabal: ["3.10.2.1"]
ghc: ["8.6.5", "8.8.4", "8.10.4", "9.0.2", "9.2.2", "9.4.5", "9.6.2", "9.8.1"]
env:
CONFIG: "--enable-tests --enable-benchmarks "
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Advantages:
- `ON` clause is attached directly to the relevant join, so you never need to
worry about how they're ordered, nor will you ever run into bugs where the
`on` clause is on the wrong `JOIN`
- The `ON` clause lambda will all the available tables in it. This forbids
- The `ON` clause lambda will exclusively have all the available tables in it. This forbids
runtime errors where an `ON` clause refers to a table that isn't in scope yet.
- You can join on a table twice, and the aliases work out fine with the `ON`
clause.
Expand Down
55 changes: 55 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,61 @@
- Change SqlExpr type to alias for new SqlExpr_ allowing for value "contexts". Currently used by window functions to avoid allowing double windowing. This change lays the groundwork for aggregate values as being contextually different from single values.
- Add support for window functions in Postgres module

3.5.11.2
========
- @arguri
- [#387](https://github.com/bitemyapp/esqueleto/pull/387)
- Fix build for ghc 9.8.1 / template-haskell 2.18

3.5.11.0
========
- @9999years, @halogenandtoast
- [#378](https://github.com/bitemyapp/esqueleto/pull/378)
- `ToMaybe` instances are now derived for records so you can now left
join them in queries

3.5.10.3
========
- @ttuegel
- [#377](https://github.com/bitemyapp/esqueleto/pull/377)
- Fix Postgres syntax for `noWait`

3.5.10.2
========
- @parsonsmatt
- [#376](https://github.com/bitemyapp/esqueleto/pull/376)
- When using Postgres 15, `LIMIT`, and the `locking` functions, you
could accidentally construct SQL code like:

> ... LIMIT 1FOR UPDATE ...

This parsed on Postgres <15, but the new Postgres parser is more
strict, and fails to parse. This PR introduces newlines between each
query chunk, which fixes the issue.

3.5.10.1
========
- @9999years
- [#369](https://github.com/bitemyapp/esqueleto/pull/369)
- Fix `myAge` type in `deriveEsqueletoRecord` documentation

3.5.10.0
========
- @ivanbakel
- [#328](https://github.com/bitemyapp/esqueleto/pull/328)
- Add `ToAlias` instances for 9- to 16-tuples
- Add `ToAliasReference` instances for 9- to 16-tuples
- @parsonsmatt
- [#365](https://github.com/bitemyapp/esqueleto/pull/365)
- Add `isNothing_` and `groupBy_` to avoid name conflicts with
`Data.List` and `Data.Maybe`.

3.5.9.1
=======
- @duplode
- [#363](https://github.com/bitemyapp/esqueleto/pull/363)
- Add missing `just` to left join examples in the Haddocks

3.5.9.0
=======
- @9999years
Expand Down
2 changes: 1 addition & 1 deletion esqueleto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ library
, resourcet >=1.2
, tagged >=0.2
, template-haskell
, text >=0.11 && <2.1
, text >=0.11 && <2.2
, time >=1.5.0.1 && <=1.13
, transformers >=0.2
, unliftio
Expand Down
10 changes: 6 additions & 4 deletions src/Database/Esqueleto/Experimental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module Database.Esqueleto.Experimental {-# WARNING "This module will be removed
-- * The Normal Stuff
, where_
, groupBy
, groupBy_
, orderBy
, rand
, asc
Expand All @@ -85,6 +86,7 @@ module Database.Esqueleto.Experimental {-# WARNING "This module will be removed

, val
, isNothing
, isNothing_
, just
, nothing
, joinV
Expand Down Expand Up @@ -338,8 +340,8 @@ import Database.Esqueleto.Experimental.ToMaybe
-- @
-- select $
-- from $ \\(people \`LeftOuterJoin\` blogPosts) -> do
-- on (people ^. PersonId ==. blogPosts ?. BlogPostAuthorId)
-- where_ (people ^. PersonAge >. val 18)
-- on (just (people ^. PersonId) ==. blogPosts ?. BlogPostAuthorId)
-- where_ (people ^. PersonAge >. just (val 18))
-- pure (people, blogPosts)
-- @
--
Expand All @@ -353,8 +355,8 @@ import Database.Esqueleto.Experimental.ToMaybe
-- from $ table \@Person
-- \`leftJoin\` table \@BlogPost
-- \`on\` (\\(people :& blogPosts) ->
-- people ^. PersonId ==. blogPosts ?. BlogPostAuthorId)
-- where_ (people ^. PersonAge >. val 18)
-- just (people ^. PersonId) ==. blogPosts ?. BlogPostAuthorId)
-- where_ (people ^. PersonAge >. just (val 18))
-- pure (people, blogPosts)
-- @
--
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Esqueleto/Experimental/From/Join.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ crossJoinLateral lhs rhsFn = From $ do
-- from $ table \@Person
-- \`leftJoin\` table \@BlogPost
-- \`on\` (\\(p :& bp) ->
-- p ^. PersonId ==. bp ?. BlogPostAuthorId)
-- just (p ^. PersonId) ==. bp ?. BlogPostAuthorId)
-- @
--
-- @since 3.5.0.0
Expand Down
124 changes: 124 additions & 0 deletions src/Database/Esqueleto/Experimental/ToAlias.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,127 @@ instance ( ToAlias a
, ToAlias h
) => ToAlias (a,b,c,d,e,f,g,h) where
toAlias x = to8 <$> (toAlias $ from8 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
) => ToAlias (a,b,c,d,e,f,g,h,i) where
toAlias x = to9 <$> (toAlias $ from9 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
) => ToAlias (a,b,c,d,e,f,g,h,i,j) where
toAlias x = to10 <$> (toAlias $ from10 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k) where
toAlias x = to11 <$> (toAlias $ from11 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
, ToAlias l
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k,l) where
toAlias x = to12 <$> (toAlias $ from12 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
, ToAlias l
, ToAlias m
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k,l,m) where
toAlias x = to13 <$> (toAlias $ from13 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
, ToAlias l
, ToAlias m
, ToAlias n
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
toAlias x = to14 <$> (toAlias $ from14 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
, ToAlias l
, ToAlias m
, ToAlias n
, ToAlias o
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
toAlias x = to15 <$> (toAlias $ from15 x)

instance ( ToAlias a
, ToAlias b
, ToAlias c
, ToAlias d
, ToAlias e
, ToAlias f
, ToAlias g
, ToAlias h
, ToAlias i
, ToAlias j
, ToAlias k
, ToAlias l
, ToAlias m
, ToAlias n
, ToAlias o
, ToAlias p
) => ToAlias (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) where
toAlias x = to16 <$> (toAlias $ from16 x)
124 changes: 124 additions & 0 deletions src/Database/Esqueleto/Experimental/ToAliasReference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,127 @@ instance ( ToAliasReference a a'
, ToAliasReference h h'
) => ToAliasReference (a,b,c,d,e,f,g,h) (a',b',c',d',e',f',g',h') where
toAliasReference ident x = to8 <$> (toAliasReference ident $ from8 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
) => ToAliasReference (a,b,c,d,e,f,g,h,i) (a',b',c',d',e',f',g',h',i') where
toAliasReference ident x = to9 <$> (toAliasReference ident $ from9 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j) (a',b',c',d',e',f',g',h',i',j') where
toAliasReference ident x = to10 <$> (toAliasReference ident $ from10 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k) (a',b',c',d',e',f',g',h',i',j',k') where
toAliasReference ident x = to11 <$> (toAliasReference ident $ from11 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
, ToAliasReference l l'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k,l) (a',b',c',d',e',f',g',h',i',j',k',l') where
toAliasReference ident x = to12 <$> (toAliasReference ident $ from12 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
, ToAliasReference l l'
, ToAliasReference m m'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k,l,m) (a',b',c',d',e',f',g',h',i',j',k',l',m') where
toAliasReference ident x = to13 <$> (toAliasReference ident $ from13 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
, ToAliasReference l l'
, ToAliasReference m m'
, ToAliasReference n n'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k,l,m,n) (a',b',c',d',e',f',g',h',i',j',k',l',m',n') where
toAliasReference ident x = to14 <$> (toAliasReference ident $ from14 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
, ToAliasReference l l'
, ToAliasReference m m'
, ToAliasReference n n'
, ToAliasReference o o'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) (a',b',c',d',e',f',g',h',i',j',k',l',m',n',o') where
toAliasReference ident x = to15 <$> (toAliasReference ident $ from15 x)

instance ( ToAliasReference a a'
, ToAliasReference b b'
, ToAliasReference c c'
, ToAliasReference d d'
, ToAliasReference e e'
, ToAliasReference f f'
, ToAliasReference g g'
, ToAliasReference h h'
, ToAliasReference i i'
, ToAliasReference j j'
, ToAliasReference k k'
, ToAliasReference l l'
, ToAliasReference m m'
, ToAliasReference n n'
, ToAliasReference o o'
, ToAliasReference p p'
) => ToAliasReference (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) (a',b',c',d',e',f',g',h',i',j',k',l',m',n',o',p') where
toAliasReference ident x = to16 <$> (toAliasReference ident $ from16 x)
Loading
Loading