Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
abc718a
Add missing just to left join examples in the Haddocks (#363)
duplode Jun 8, 2023
494fe5d
Name conflict dodges (#365)
parsonsmatt Jun 8, 2023
6f884d8
Add `ToAlias`, `ToAliasReference` for <=16-tuples (#328)
ivanbakel Jun 8, 2023
b782593
Fix `myAge` type in `deriveEsqueletoRecord` documentation (#369)
9999years Jul 31, 2023
e50fed1
Newlines between query chunks (#376)
parsonsmatt Aug 29, 2023
d805bb0
Fix Postgres syntax for NOWAIT (#377)
ttuegel Sep 7, 2023
bd33498
README.md: Fix missing words (#380)
isomorpheme Oct 4, 2023
a69ce68
Generate `ToMaybe` in `deriveEsqueletoRecord` (#378)
halogenandtoast Oct 24, 2023
f689e22
Version bump for text (#384)
parsonsmatt Jan 2, 2024
30a5e80
fix build for ghc 9.8.1 (#386) (#387)
arguri Feb 9, 2024
eb719e7
Add dependencies to nix packages in stack.yaml (#403)
csamak Oct 17, 2024
603e083
Fix some shouldSatisfy predicates that were always True (#404)
csamak Oct 17, 2024
d5df118
Add support for nested Maybe records (#405)
csamak Oct 22, 2024
ba43f65
add all postgres row-level locking options (#402)
ac251 Oct 24, 2024
2b8f2cf
Do not error on any AppT in sqlMaybeSelectProcessRowDec (#406)
csamak Dec 5, 2024
c0a381e
Fix semantics of `not_` applied over `&&.` and `||.` (#379)
blujupiter32 Dec 26, 2024
7f77bec
start 3.5.13.2
parsonsmatt Dec 26, 2024
a14ec3a
Use TH quotes more to eliminate some CPP (#394)
TeofilC Dec 26, 2024
9631275
Update CI (#409)
parsonsmatt Dec 26, 2024
7c5cb0e
Docs on boolean operators (#411)
parsonsmatt Dec 26, 2024
2583e74
Mattp/incorporate cte aliasing (#410)
parsonsmatt Dec 26, 2024
91aa8d2
v3.5.13.2
parsonsmatt Dec 26, 2024
235bd9a
Derive Traversable for Value (#414)
parsonsmatt Dec 26, 2024
cdece91
Add NULLS FIRST / NULLS LAST qualifiers for ordering (#341)
matthewbauer Dec 26, 2024
28c8130
Add changelog entry for #341
parsonsmatt Dec 26, 2024
bc9c169
Add Functor and Bifunctor instance for pairs (#416)
parsonsmatt Dec 26, 2024
324de6a
Export SqlSelect from Database.Esqueleto.Experimental (#415)
parsonsmatt Dec 26, 2024
e739a91
Jnm/add cte materialized to postgres (#417)
parsonsmatt Dec 26, 2024
6ea947a
v3.5.14.0
parsonsmatt Dec 26, 2024
135f828
oof
parsonsmatt Dec 27, 2024
f54a84b
fix the ci
parsonsmatt Dec 27, 2024
c0f4db4
All tests are passing now
parsonsmatt Dec 27, 2024
a9a3a03
remove cruft
parsonsmatt Dec 27, 2024
9298406
remove comments from merge
parsonsmatt Dec 27, 2024
7821cbe
Version 3.6.0.0 (#419)
parsonsmatt Jan 13, 2025
e299b04
it builds
parsonsmatt Jan 13, 2025
233e635
Fix export
parsonsmatt Apr 15, 2025
91a7ae4
groupBy_
parsonsmatt Apr 15, 2025
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
21 changes: 16 additions & 5 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ jobs:
strategy:
matrix:
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"]
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@v2
- uses: haskell/actions/setup@v2
- uses: actions/checkout@v4
- uses: haskell-actions/setup@v2
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
Expand All @@ -59,9 +69,10 @@ jobs:
# mysql database: 'esqutest' # Optional, default value is "test". The specified database which will be create
# mysql user: 'travis' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
# mysql password: 'esqutest' # Required if "mysql user" exists. The password for the "mysql user"
- run: sudo apt-get update && sudo apt-get install -y libpcre3-dev
- 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 +83,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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ clean:
$(STACK) clean

.PHONY: init-pgsql

init-pgsql:
sudo -u postgres -- createuser -s esqutest

Expand Down
129 changes: 129 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,135 @@
- 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.6.0.0
=======
- @parsonsmatt
- [#422](https://github.com/bitemyapp/esqueleto/pull/422)
- The instance of `HasField` for `SqlExpr (Maybe (Entity a))` joins
`Maybe` values together. This means that if you `leftJoin` a table
with a `Maybe` column, the result will be a `SqlExpr (Value (Maybe
typ))`, instead of `SqlExpr (Value (Maybe (Maybe typ)))`.
- To make this a less breaking change, `joinV` has been given a similar
behavior. If the input type to `joinV` is `Maybe (Maybe typ)`, then
the result becomes `Maybe typ`. If the input type is `Maybe typ`, then
the output is also `Maybe typ`. The `joinV'` function is given as an
alternative with monomorphic behavior.
- The `just` function is also modified to avoid nesting `Maybe`.
Likewise, `just'` is provided to give monomorphic behavior.
- `subSelect`, `max_`, `min_`, and `coalesce` were all
given `Nullable` output types as well. This should help to reduce the
incidence of nested `Maybe`.
- The operator `??.` was introduced which can do nested `Maybe`. You may
want this if you have type inference issues with `?.` combining
`Maybe`.
- [#420](https://github.com/bitemyapp/esqueleto/pull/420)
- Add a fixity declaration to `?.`
- [#412](https://github.com/bitemyapp/esqueleto/pull/412)
- The `random_` and `rand` functions (deprecated in 2.6.0) have been
removed. Please refer to the database specific ones (ie
`Database.Esqueleto.PostgreSQL` etc)
- The `sub_select` function (deprecated in 3.2.0) has been removed.
Please use the safer variants like `subSelect`, `subSelectMaybe`, etc.
- The `ToAliasT` and `ToAliasReferenceT` types has been removed after having been deprecated in 3.4.0.1.
- The `Union` type (deprecated in 3.4) was removed. Please use `union_`
instead.
- The `UnionAll` type (deprecated in 3.4) was removed. Please use
`unionAll_` instead.
- The `Except` type (deprecated in 3.4) was removed. Please use
`except_` instead.
- The `Intersect` type (deprecated in 3.4) was removed. Please use
`intersect_` instead.
- The `SubQuery` type (deprecated in 3.4) was removed. You do not need
to tag subqueries to use them in `from` clauses.
- The `SelectQuery` type (deprecated in 3.4) was removed. You do not
need to tag `SqlQuery` values with `SelectQuery`.
- [#287](https://github.com/bitemyapp/esqueleto/pull/278)
- Deprecate `distinctOn` and `distinctOnOrderBy`. Use the variants
defined in `PostgreSQL` module instead. The signature has changed, but
the refactor is straightforward:
```
-- old:
p <- from $ table
distinctOn [don x] $ do
pure p

-- new:
p <- from $ table
distinctOn [don x]
pure p
```
- [#301](https://github.com/bitemyapp/esqueleto/pull/301)
- Postgresql `upsert` and `upsertBy` now require a `NonEmpty` list of
updates. If you want to provide an empty list of updates, you'll need
to use `upsertMaybe` and `upsertMaybeBe` instead. Postgres does not
return rows from the database if no updates are performed.
- [#413](https://github.com/bitemyapp/esqueleto/pull/413)
- The ability to `coerce` `SqlExpr` was removed. Instead, use
`veryUnsafeCoerceSqlExpr`. See the documentation on
`veryUnsafeCoerceSqlExpr` for safe use example.
- `unsafeCeorceSqlExpr` is provided as an option when the underlying
Haskell types are coercible. This is still unsafe, as different
`PersistFieldSql` instances may be at play.
- [#420](https://github.com/bitemyapp/esqueleto/pull/421)
- The `LockingKind` constructors are deprecated, and will be removed
from non-Internal modules in a future release. Smart constructors
replace them, and you may need to import them from a different
database-specific module.
- [#425](https://github.com/bitemyapp/esqueleto/pull/425)
- `fromBaseId` is introduced as the inverse of `toBaseId`.
- `toBaseIdMaybe` and `fromBaseIdMaybe` are introduced.

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
6 changes: 4 additions & 2 deletions esqueleto.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cabal-version: 1.12

name: esqueleto

version: 4.0.0.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.
Expand Down Expand Up @@ -56,7 +55,7 @@ library
hs-source-dirs:
src/
build-depends:
base >=4.8 && <5.0
base >=4.12 && <5.0
, aeson >=1.0
, attoparsec >= 0.13 && < 0.15
, blaze-html
Expand Down Expand Up @@ -84,13 +83,16 @@ library
-Wcpp-undef
-Wcpp-undef
default-language: Haskell2010
default-extensions:
TypeOperators

test-suite specs
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Common.Test
Common.LegacyTest
Common.Test.CTE
Common.Test.Models
Common.Test.Import
Common.Test.Select
Expand Down
2 changes: 1 addition & 1 deletion examples/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Control.Monad.Reader (MonadReader(..), runReaderT)
import Control.Monad.Trans.Control (MonadBaseControl)
import Database.Esqueleto.Experimental
import Database.Persist.Postgresql (ConnectionString, withPostgresqlConn)
import qualified Database.Persist.Sql as Persistent
import Database.Persist.TH
( mkMigrate
, mkPersist
Expand All @@ -36,7 +37,6 @@ import Database.Persist.TH
, sqlSettings
)


share [ mkPersist sqlSettings
, mkMigrate "migrateAll"] [persistLowerCase|
Person
Expand Down
49 changes: 39 additions & 10 deletions src/Database/Esqueleto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,45 @@ module Database.Esqueleto
from
, table
, Table(..)
, SubQuery(..)
, selectQuery

-- * @esqueleto@'s Language
, where_, on, groupBy, orderBy, asc, desc, limit, offset
, distinct, distinctOn, don, distinctOnOrderBy, having, locking
, (^.), (?.)
, val, isNothing, isNothing_, just, just', nothing, joinV, joinV', withNonNull
, countRows, count, countDistinct
, not_, (==.), (>=.), (>.), (<=.), (<.), (!=.), (&&.), (||.)
, between, (+.), (-.), (/.), (*.)
, round_, ceiling_, floor_
, min_, max_, sum_, avg_, castNum, castNumM
, coalesce, coalesceDefault
, lower_, upper_, trim_, ltrim_, rtrim_, length_, left_, right_
, like, ilike, (%), concat_, (++.), castString
, subList_select, valList, justList
, in_, notIn, exists, notExists
, set, (=.), (+=.), (-=.), (*=.), (/=.)
, case_, toBaseId, fromBaseId, toBaseIdMaybe, fromBaseIdMaybe
, subSelect
, subSelectMaybe
, subSelectCount
, subSelectForeign
, subSelectList
, subSelectUnsafe
, ToBaseId(..)
, when_
, then_
, else_
, from
, Value(..)
, ValueList(..)
, OrderBy
, DistinctOn
, LockingKind(..)
, forUpdate
, forUpdateSkipLocked
, LockableEntity(..)
, SqlString
-- ** Joins
, (:&)(..)
, on
Expand All @@ -75,14 +111,9 @@ module Database.Esqueleto
-- ** Set Operations
-- $sql-set-operations
, union_
, Union(..)
, unionAll_
, UnionAll(..)
, except_
, Except(..)
, intersect_
, Intersect(..)
, pattern SelectQuery

-- ** Common Table Expressions
, with
Expand All @@ -92,16 +123,14 @@ module Database.Esqueleto
, From(..)
, ToMaybe(..)
, ToAlias(..)
, ToAliasT
, ToAliasReference(..)
, ToAliasReferenceT
, ToSqlSetOperation(..)

-- * The Normal Stuff
, where_
, groupBy
, groupBy_
, orderBy
, rand
, asc
, desc
, limit
Expand All @@ -114,12 +143,12 @@ module Database.Esqueleto
, having
, locking

, sub_select
, (^.)
, (?.)

, val
, isNothing
, isNothing_
, just
, nothing
, joinV
Expand Down
Loading
Loading