Skip to content

Commit

Permalink
feat: PR prep cleanup; changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ulidtko committed Jun 15, 2023
1 parent ca40af5 commit 53ef334
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.5.10.1 (unreleased)
=======
- @ulidtko
- PR TBD
- Add `updateReturning`, `deleteReturning` as Postgres extensions.

3.5.10.0
=======
- @ivanbakel
Expand All @@ -15,7 +21,6 @@
- [#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
9 changes: 4 additions & 5 deletions src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1882,9 +1882,7 @@ data CommonTableExpressionClause =

data ReturningClause
= ReturningNothing -- ^ The default, absent clause.
| ReturningStar -- ^ @RETURNING *@
-- | ReturningExprs (NonEmpty (SqlExpr Returning))
-- ^ @output_expression [ [ AS ] output_name ] [, ...]@
| ReturningStar -- ^ @RETURNING@ is present.

data SubQueryType
= NormalSubQuery
Expand Down Expand Up @@ -2128,7 +2126,6 @@ instance Semigroup ReturningClause where
(<>) ReturningNothing x = x
(<>) x ReturningNothing = x
(<>) ReturningStar ReturningStar = ReturningStar
-- (<>) _ _ = error "instance Semigroup FIXME"

instance Monoid ReturningClause where
mempty = ReturningNothing
Expand Down Expand Up @@ -2421,6 +2418,9 @@ existsHelper = sub SELECT . (>> return true)
--
-- Many constructs appearing in @SELECT@ can go under @RETURNING@ -- but not all (e.g.
-- certainly not subqueries, @VALUES@ and such). Thus, this is a subclass of 'SqlSelect'.
--
-- The fundeps duplicate those of 'SqlSelect' solely to provide somewhat more directly
-- understandable type errors.
class SqlSelect a r => InferReturning a r | r -> a, a -> r
instance PersistEntity ent => InferReturning (SqlExpr (Entity ent)) (Entity ent)
instance PersistEntity ent => InferReturning (SqlExpr (Maybe (Entity ent))) (Maybe (Entity ent))
Expand Down Expand Up @@ -3314,7 +3314,6 @@ makeReturning :: SqlSelect a r
=> IdentInfo -> ReturningClause -> a -> (TLB.Builder, [PersistValue])
makeReturning _ ReturningNothing _ = mempty
makeReturning info ReturningStar ret = ("RETURNING ", []) <> sqlSelectCols info ret
-- makeReturning info (ReturningExprs _) = undefined -- FIXME


parens :: TLB.Builder -> TLB.Builder
Expand Down
2 changes: 1 addition & 1 deletion test/PostgreSQL/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ testUpsert =

testUpdateDeleteReturning :: SpecDb
testUpdateDeleteReturning =
describe "UPDATE .. RETURNING *" $ do
describe "UPDATE .. RETURNING .." $ do
itDb "Whole entities, expressions and tuples get returned from UPDATE" $ do
[_p1k, _p2k, _p3k, p4k, _p5k] <- mapM insert [p1, p2, p3, p4, p5]
ret1 <- EP.updateReturning $ \p -> do
Expand Down

0 comments on commit 53ef334

Please sign in to comment.