Skip to content

Commit 7821cbe

Browse files
authored
Version 3.6.0.0 (#419)
* Remove `Coercible` abiilty for `SqlExpr`. (#413) * Remove Coercible * Remove coercible * update docs and changelog * Support upsert with empty updates (#301) * Support upsert with empty updates * stylish, changelog link * clean * remove focus * oh no * update with new api * tests pass * Fix distinctOn (#287) * Fix distinctOn * lol * expose * Deprecation Cycles for 3.6 (#412) * Deprecate ilike outside of Postgres * lol * Deprecation Cycling * wow okay cool * oh woops * Add fixity on question-dot operator (#420) * Add fixity on question-dot operator * changelog link * Deprecate LockingKind constructors (#421) * Deprecate LockingKind constructors * changelog * `HasField` for `SqlExpr (Maybe (Entity a))` joins `Maybe` (#422) * HasField on SqlExpr (Maybe Entity) joins Maybe * hmmm that works kinda nicely * Incorporate changes from the work codebase * add another test case * changelog * wat * wat * wat * 3.6 fixups (#425) * Re-export Nullable from ToMaybe * Fixity on ilike * lolwhoops * changelog link * add toBaseIdMaybe and fromBaseIdMaybe * start sketching out the sqlcoerce class * no sqlcoerce yet * ok for convenience
1 parent 6ea947a commit 7821cbe

File tree

22 files changed

+711
-284
lines changed

22 files changed

+711
-284
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
# mysql database: 'esqutest' # Optional, default value is "test". The specified database which will be create
7070
# mysql user: 'travis' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
7171
# mysql password: 'esqutest' # Required if "mysql user" exists. The password for the "mysql user"
72+
- run: sudo apt-get update && sudo apt-get install -y libpcre3-dev
7273
- run: cabal v2-update
7374
- run: cabal v2-freeze $CONFIG
7475
- uses: actions/cache@v4

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ clean:
5858
$(STACK) clean
5959

6060
.PHONY: init-pgsql
61+
6162
init-pgsql:
6263
sudo -u postgres -- createuser -s esqutest
6364

changelog.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
1+
3.6.0.0
2+
=======
3+
- @parsonsmatt
4+
- [#422](https://github.com/bitemyapp/esqueleto/pull/422)
5+
- The instance of `HasField` for `SqlExpr (Maybe (Entity a))` joins
6+
`Maybe` values together. This means that if you `leftJoin` a table
7+
with a `Maybe` column, the result will be a `SqlExpr (Value (Maybe
8+
typ))`, instead of `SqlExpr (Value (Maybe (Maybe typ)))`.
9+
- To make this a less breaking change, `joinV` has been given a similar
10+
behavior. If the input type to `joinV` is `Maybe (Maybe typ)`, then
11+
the result becomes `Maybe typ`. If the input type is `Maybe typ`, then
12+
the output is also `Maybe typ`. The `joinV'` function is given as an
13+
alternative with monomorphic behavior.
14+
- The `just` function is also modified to avoid nesting `Maybe`.
15+
Likewise, `just'` is provided to give monomorphic behavior.
16+
- `subSelect`, `max_`, `min_`, and `coalesce` were all
17+
given `Nullable` output types as well. This should help to reduce the
18+
incidence of nested `Maybe`.
19+
- The operator `??.` was introduced which can do nested `Maybe`. You may
20+
want this if you have type inference issues with `?.` combining
21+
`Maybe`.
22+
- [#420](https://github.com/bitemyapp/esqueleto/pull/420)
23+
- Add a fixity declaration to `?.`
24+
- [#412](https://github.com/bitemyapp/esqueleto/pull/412)
25+
- The `random_` and `rand` functions (deprecated in 2.6.0) have been
26+
removed. Please refer to the database specific ones (ie
27+
`Database.Esqueleto.PostgreSQL` etc)
28+
- The `sub_select` function (deprecated in 3.2.0) has been removed.
29+
Please use the safer variants like `subSelect`, `subSelectMaybe`, etc.
30+
- The `ToAliasT` and `ToAliasReferenceT` types has been removed after having been deprecated in 3.4.0.1.
31+
- The `Union` type (deprecated in 3.4) was removed. Please use `union_`
32+
instead.
33+
- The `UnionAll` type (deprecated in 3.4) was removed. Please use
34+
`unionAll_` instead.
35+
- The `Except` type (deprecated in 3.4) was removed. Please use
36+
`except_` instead.
37+
- The `Intersect` type (deprecated in 3.4) was removed. Please use
38+
`intersect_` instead.
39+
- The `SubQuery` type (deprecated in 3.4) was removed. You do not need
40+
to tag subqueries to use them in `from` clauses.
41+
- The `SelectQuery` type (deprecated in 3.4) was removed. You do not
42+
need to tag `SqlQuery` values with `SelectQuery`.
43+
- [#287](https://github.com/bitemyapp/esqueleto/pull/278)
44+
- Deprecate `distinctOn` and `distinctOnOrderBy`. Use the variants
45+
defined in `PostgreSQL` module instead. The signature has changed, but
46+
the refactor is straightforward:
47+
```
48+
-- old:
49+
p <- from $ table
50+
distinctOn [don x] $ do
51+
pure p
52+
53+
-- new:
54+
p <- from $ table
55+
distinctOn [don x]
56+
pure p
57+
```
58+
- [#301](https://github.com/bitemyapp/esqueleto/pull/301)
59+
- Postgresql `upsert` and `upsertBy` now require a `NonEmpty` list of
60+
updates. If you want to provide an empty list of updates, you'll need
61+
to use `upsertMaybe` and `upsertMaybeBe` instead. Postgres does not
62+
return rows from the database if no updates are performed.
63+
- [#413](https://github.com/bitemyapp/esqueleto/pull/413)
64+
- The ability to `coerce` `SqlExpr` was removed. Instead, use
65+
`veryUnsafeCoerceSqlExpr`. See the documentation on
66+
`veryUnsafeCoerceSqlExpr` for safe use example.
67+
- `unsafeCeorceSqlExpr` is provided as an option when the underlying
68+
Haskell types are coercible. This is still unsafe, as different
69+
`PersistFieldSql` instances may be at play.
70+
- [#420](https://github.com/bitemyapp/esqueleto/pull/421)
71+
- The `LockingKind` constructors are deprecated, and will be removed
72+
from non-Internal modules in a future release. Smart constructors
73+
replace them, and you may need to import them from a different
74+
database-specific module.
75+
- [#425](https://github.com/bitemyapp/esqueleto/pull/425)
76+
- `fromBaseId` is introduced as the inverse of `toBaseId`.
77+
- `toBaseIdMaybe` and `fromBaseIdMaybe` are introduced.
78+
179
3.5.14.0
280
========
381
- @parsonsmatt

esqueleto.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
cabal-version: 1.12
22

33
name: esqueleto
4-
5-
version: 3.5.14.0
4+
version: 3.6.0.0
65
synopsis: Type-safe EDSL for SQL queries on persistent backends.
76
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.
87
.
@@ -53,7 +52,7 @@ library
5352
hs-source-dirs:
5453
src/
5554
build-depends:
56-
base >=4.8 && <5.0
55+
base >=4.12 && <5.0
5756
, aeson >=1.0
5857
, attoparsec >= 0.13 && < 0.15
5958
, blaze-html

examples/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Control.Monad.Reader (MonadReader(..), runReaderT)
2828
import Control.Monad.Trans.Control (MonadBaseControl)
2929
import Database.Esqueleto.Experimental
3030
import Database.Persist.Postgresql (ConnectionString, withPostgresqlConn)
31+
import qualified Database.Persist.Sql as Persistent
3132
import Database.Persist.TH
3233
( mkMigrate
3334
, mkPersist
@@ -36,7 +37,6 @@ import Database.Persist.TH
3637
, sqlSettings
3738
)
3839

39-
4040
share [ mkPersist sqlSettings
4141
, mkMigrate "migrateAll"] [persistLowerCase|
4242
Person

src/Database/Esqueleto.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ module Database.Esqueleto {-# WARNING "This module will switch over to the Exper
5151
-- $gettingstarted
5252

5353
-- * @esqueleto@'s Language
54-
where_, on, groupBy, orderBy, rand, asc, desc, limit, offset
54+
where_, on, groupBy, orderBy, asc, desc, limit, offset
5555
, distinct, distinctOn, don, distinctOnOrderBy, having, locking
56-
, sub_select, (^.), (?.)
57-
, val, isNothing, just, nothing, joinV, withNonNull
56+
, (^.), (?.)
57+
, val, isNothing, just, just', nothing, joinV, joinV', withNonNull
5858
, countRows, count, countDistinct
5959
, not_, (==.), (>=.), (>.), (<=.), (<.), (!=.), (&&.), (||.)
6060
, between, (+.), (-.), (/.), (*.)
61-
, random_, round_, ceiling_, floor_
61+
, round_, ceiling_, floor_
6262
, min_, max_, sum_, avg_, castNum, castNumM
6363
, coalesce, coalesceDefault
6464
, lower_, upper_, trim_, ltrim_, rtrim_, length_, left_, right_
6565
, like, ilike, (%), concat_, (++.), castString
6666
, subList_select, valList, justList
6767
, in_, notIn, exists, notExists
6868
, set, (=.), (+=.), (-=.), (*=.), (/=.)
69-
, case_, toBaseId
69+
, case_, toBaseId, fromBaseId, toBaseIdMaybe, fromBaseIdMaybe
7070
, subSelect
7171
, subSelectMaybe
7272
, subSelectCount
@@ -83,6 +83,8 @@ module Database.Esqueleto {-# WARNING "This module will switch over to the Exper
8383
, OrderBy
8484
, DistinctOn
8585
, LockingKind(..)
86+
, forUpdate
87+
, forUpdateSkipLocked
8688
, LockableEntity(..)
8789
, SqlString
8890
-- ** Joins

src/Database/Esqueleto/Experimental.hs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Database.Esqueleto.Experimental
2222
from
2323
, table
2424
, Table(..)
25-
, SubQuery(..)
2625
, selectQuery
2726

2827
-- ** Joins
@@ -40,14 +39,9 @@ module Database.Esqueleto.Experimental
4039
-- ** Set Operations
4140
-- $sql-set-operations
4241
, union_
43-
, Union(..)
4442
, unionAll_
45-
, UnionAll(..)
4643
, except_
47-
, Except(..)
4844
, intersect_
49-
, Intersect(..)
50-
, pattern SelectQuery
5145

5246
-- ** Common Table Expressions
5347
, with
@@ -57,18 +51,16 @@ module Database.Esqueleto.Experimental
5751
, From(..)
5852
, ToMaybe(..)
5953
, ToAlias(..)
60-
, ToAliasT
6154
, ToAliasReference(..)
62-
, ToAliasReferenceT
6355
, ToSqlSetOperation(..)
6456
, SqlSelect
57+
, Nullable
6558

6659
-- * The Normal Stuff
6760
, where_
6861
, groupBy
6962
, groupBy_
7063
, orderBy
71-
, rand
7264
, asc
7365
, desc
7466
, limit
@@ -80,8 +72,9 @@ module Database.Esqueleto.Experimental
8072
, distinctOnOrderBy
8173
, having
8274
, locking
75+
, forUpdate
76+
, forUpdateSkipLocked
8377

84-
, sub_select
8578
, (^.)
8679
, (?.)
8780

@@ -113,7 +106,6 @@ module Database.Esqueleto.Experimental
113106
, (/.)
114107
, (*.)
115108

116-
, random_
117109
, round_
118110
, ceiling_
119111
, floor_
@@ -162,6 +154,9 @@ module Database.Esqueleto.Experimental
162154

163155
, case_
164156
, toBaseId
157+
, toBaseIdMaybe
158+
, fromBaseId
159+
, fromBaseIdMaybe
165160
, subSelect
166161
, subSelectMaybe
167162
, subSelectCount

src/Database/Esqueleto/Experimental/From.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ table = From $ do
9898
)
9999

100100

101-
{-# DEPRECATED SubQuery "/Since: 3.4.0.0/ - It is no longer necessary to tag 'SqlQuery' values with @SubQuery@" #-}
102-
newtype SubQuery a = SubQuery a
103-
instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SubQuery (SqlQuery a)) a where
104-
toFrom (SubQuery q) = selectQuery q
105101
instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SqlQuery a) a where
106102
toFrom = selectQuery
107103

src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ mkSetOperation operation lhs rhs = SqlSetOperation $ \p -> do
7474
(_, rightClause) <- unSqlSetOperation (toSqlSetOperation rhs) p
7575
pure (leftValue, \info -> leftClause info <> (operation, mempty) <> rightClause info)
7676

77-
{-# DEPRECATED Union "/Since: 3.4.0.0/ - Use the 'union_' function instead of the 'Union' data constructor" #-}
78-
data Union a b = a `Union` b
79-
instance ToSqlSetOperation a a' => ToSqlSetOperation (Union a a) a' where
80-
toSqlSetOperation (Union a b) = union_ a b
81-
8277
-- | Overloaded @union_@ function to support use in both 'SqlSetOperation'
8378
-- and 'withRecursive'
8479
--
@@ -102,30 +97,10 @@ instance (ToSqlSetOperation a c, ToSqlSetOperation b c, res ~ SqlSetOperation c)
10297
=> UnionAll_ (a -> b -> res) where
10398
unionAll_ = mkSetOperation " UNION ALL "
10499

105-
{-# DEPRECATED UnionAll "/Since: 3.4.0.0/ - Use the 'unionAll_' function instead of the 'UnionAll' data constructor" #-}
106-
data UnionAll a b = a `UnionAll` b
107-
instance ToSqlSetOperation a a' => ToSqlSetOperation (UnionAll a a) a' where
108-
toSqlSetOperation (UnionAll a b) = unionAll_ a b
109-
110-
{-# DEPRECATED Except "/Since: 3.4.0.0/ - Use the 'except_' function instead of the 'Except' data constructor" #-}
111-
data Except a b = a `Except` b
112-
instance ToSqlSetOperation a a' => ToSqlSetOperation (Except a a) a' where
113-
toSqlSetOperation (Except a b) = except_ a b
114-
115100
-- | @EXCEPT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.
116101
except_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
117102
except_ = mkSetOperation " EXCEPT "
118103

119-
{-# DEPRECATED Intersect "/Since: 3.4.0.0/ - Use the 'intersect_' function instead of the 'Intersect' data constructor" #-}
120-
data Intersect a b = a `Intersect` b
121-
instance ToSqlSetOperation a a' => ToSqlSetOperation (Intersect a a) a' where
122-
toSqlSetOperation (Intersect a b) = intersect_ a b
123-
124104
-- | @INTERSECT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.
125105
intersect_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
126106
intersect_ = mkSetOperation " INTERSECT "
127-
128-
{-# DEPRECATED SelectQuery "/Since: 3.4.0.0/ - It is no longer necessary to tag 'SqlQuery' values with @SelectQuery@" #-}
129-
pattern SelectQuery :: p -> p
130-
pattern SelectQuery a = a
131-

src/Database/Esqueleto/Experimental/ToAlias.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ module Database.Esqueleto.Experimental.ToAlias
88
import Database.Esqueleto.Internal.Internal hiding (From, from, on)
99
import Database.Esqueleto.Internal.PersistentImport
1010

11-
{-# DEPRECATED ToAliasT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}
12-
type ToAliasT a = a
13-
1411
-- Tedious tuple magic
1512
class ToAlias a where
1613
toAlias :: a -> SqlQuery a

0 commit comments

Comments
 (0)