Skip to content

Commit

Permalink
oof
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt committed Dec 27, 2024
1 parent 1c38678 commit 135f828
Show file tree
Hide file tree
Showing 24 changed files with 1,202 additions and 392 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,31 @@ jobs:
strategy:
matrix:
cabal: ["3.10.2.1"]
<<<<<<< HEAD
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@v2
=======
ghc:
- "8.6"
- "8.8"
- "8.10"
- "9.0"
- "9.2"
- "9.4"
- "9.6"
- "9.8"
- "9.10"
# - "9.12"
env:
CONFIG: "--enable-tests --enable-benchmarks "
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
>>>>>>> master
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
Expand All @@ -61,7 +80,7 @@ jobs:
# mysql password: 'esqutest' # Required if "mysql user" exists. The password for the "mysql user"
- run: cabal v2-update
- run: cabal v2-freeze $CONFIG
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
Expand All @@ -72,6 +91,6 @@ jobs:
${{ runner.os }}-${{ matrix.ghc }}-
- run: cabal v2-build --disable-optimization -j $CONFIG
- run: cabal v2-test --disable-optimization -j $CONFIG --test-options "--fail-on-focus"
- if: ${{ matrix.ghc != '8.6.5' }}
- if: ${{ matrix.ghc != '8.6' }}
run: cabal v2-haddock -j $CONFIG
- run: cabal v2-sdist
51 changes: 51 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,57 @@
- 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.14.0
========
- @parsonsmatt
- [#415](https://github.com/bitemyapp/esqueleto/pull/415)
- Export the `SqlSelect` type from `Database.Esqueleto.Experimental`
- [#414](https://github.com/bitemyapp/esqueleto/pull/414)
- Derive `Foldable` and `Traversable` for `Value`.
- [#416](https://github.com/bitemyapp/esqueleto/pull/416)
- Derive `Functor` and `Bifunctor` for `:&`
- @matthewbauer
- [#341](https://github.com/bitemyapp/esqueleto/pull/341/)
- Add functions for `NULLS FIRST` and `NULLS LAST` in the Postgresql
module
- @JoelMcCracken
- [#354](https://github.com/bitemyapp/esqueleto/pull/354), [#417](https://github.com/bitemyapp/esqueleto/pull/417)
- Add `withMaterialized`, `withNotMaterialized` to the PostgreSQL module

3.5.13.2
========
- @blujupiter32
- [#379](https://github.com/bitemyapp/esqueleto/pull/379)
- Fix a bug where `not_ (a &&. b)` would be interpeted as `(not_ a) &&. b`
- @RikvanToor
- [#373](https://github.com/bitemyapp/esqueleto/pull/373), [#410](https://github.com/bitemyapp/esqueleto/pull/410)
- Fix name clashes when using CTEs multiple times
- @TeofilC
- [#394](https://github.com/bitemyapp/esqueleto/pull/394)
- Use TH quotes to eliminate some CPP.
- @parsonsmatt, @jappeace
- [#346](#https://github.com/bitemyapp/esqueleto/pull/346), [#411](https://github.com/bitemyapp/esqueleto/pull/411)
- Add docs for more SQL operators

3.5.13.1
========
- @csamak
- [#405](https://github.com/bitemyapp/esqueleto/pull/405)
- Fix a bug introduced in 3.5.12.0 where deriveEsqueletoRecord incorrectly errors

3.5.13.0
========
- @ac251
- [#402](https://github.com/bitemyapp/esqueleto/pull/402)
- Add `forNoKeyUpdate` and `forKeyShare` locking kinds for postgres

3.5.12.0
========
- @csamak
- [#405](https://github.com/bitemyapp/esqueleto/pull/405)
- `ToMaybe` instances are now derived for Maybe records.
See [Issue #401](https://github.com/bitemyapp/esqueleto/issues/401).

3.5.11.2
========
- @arguri
Expand Down
1 change: 1 addition & 0 deletions esqueleto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ test-suite specs
other-modules:
Common.Test
Common.LegacyTest
Common.Test.CTE
Common.Test.Models
Common.Test.Import
Common.Test.Select
Expand Down
1 change: 0 additions & 1 deletion src/Database/Esqueleto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ module Database.Esqueleto
, where_
, groupBy
, orderBy
, rand
, asc
, desc
, limit
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Esqueleto/Experimental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ module Database.Esqueleto.Experimental {-# WARNING "This module will be removed
, ToAliasReference(..)
, ToAliasReferenceT
, ToSqlSetOperation(..)
, SqlSelect

-- * The Normal Stuff
, where_
, groupBy
, groupBy_
, orderBy
, rand
, asc
, desc
, limit
Expand Down
15 changes: 11 additions & 4 deletions src/Database/Esqueleto/Experimental/From/CommonTableExpression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,28 @@ import Database.Esqueleto.Internal.Internal hiding (From(..), from, on)
-- PostgreSQL 12, non-recursive and side-effect-free queries may be inlined and
-- optimized accordingly if not declared @MATERIALIZED@ to get the previous
-- behaviour. See [the PostgreSQL CTE documentation](https://www.postgresql.org/docs/current/queries-with.html#id-1.5.6.12.7),
-- section Materialization, for more information.
-- section Materialization, for more information. To use a @MATERIALIZED@ query
-- in Esquelto, see functions 'withMaterialized' and 'withRecursiveMaterialized'.
--
-- /Since: 3.4.0.0/
with :: ( ToAlias a
, ToAliasReference a a'
, ToAliasReference a' a'
, SqlSelect a r
) => SqlQuery a -> SqlQuery (From a')
with query = do
(ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ query
aliasedValue <- toAlias ret
let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)
ident <- newIdentFor (DBName "cte")
let clause = CommonTableExpressionClause NormalCommonTableExpression ident (\info -> toRawSql SELECT info aliasedQuery)
let clause = CommonTableExpressionClause NormalCommonTableExpression (\_ _ -> "") ident (\info -> toRawSql SELECT info aliasedQuery)
Q $ W.tell mempty{sdCteClause = [clause]}
ref <- toAliasReference ident aliasedValue
pure $ From $ pure (ref, (\_ info -> (useIdent info ident, mempty)))
pure $ From $ do
newIdent <- newIdentFor (DBName "cte")
localRef <- toAliasReference newIdent ref
let makeLH info = useIdent info ident <> " AS " <> useIdent info newIdent
pure (localRef, (\_ info -> (makeLH info, mempty)))

-- | @WITH@ @RECURSIVE@ allows one to make a recursive subquery, which can
-- reference itself. Like @WITH@, this is supported in most modern SQL engines.
Expand Down Expand Up @@ -103,7 +109,8 @@ withRecursive baseCase unionKind recursiveCase = do
ref <- toAliasReference ident aliasedValue
let refFrom = From (pure (ref, (\_ info -> (useIdent info ident, mempty))))
let recursiveQuery = recursiveCase refFrom
let clause = CommonTableExpressionClause RecursiveCommonTableExpression ident
let noModifier _ _ = ""
let clause = CommonTableExpressionClause RecursiveCommonTableExpression noModifier ident
(\info -> (toRawSql SELECT info aliasedQuery)
<> ("\n" <> (unUnionKind unionKind) <> "\n", mempty)
<> (toRawSql SELECT info recursiveQuery)
Expand Down
Loading

0 comments on commit 135f828

Please sign in to comment.