Skip to content

Commit

Permalink
Do not error on any AppT in sqlMaybeSelectProcessRowDec (#406)
Browse files Browse the repository at this point in the history
* Do not error on any AppT in sqlMaybeSelectProcessRowDec

No need to be this restrictive in deriveEsqueletoRecord
For example, AppT ListT _ and AppT (ConT _) _ are both fine but would
throw an error here before this change.

* Apply suggestions from code review

---------

Co-authored-by: Matt Parsons <[email protected]>
  • Loading branch information
csamak and parsonsmatt authored Dec 5, 2024
1 parent ba43f65 commit 2b8f2cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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
Expand Down
2 changes: 1 addition & 1 deletion esqueleto.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cabal-version: 1.12

name: esqueleto

version: 3.5.13.0
version: 3.5.13.1
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
4 changes: 1 addition & 3 deletions src/Database/Esqueleto/Record.hs
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,8 @@ sqlMaybeSelectProcessRowDec RecordInfo {..} = do
]
where
wrapJust x = case x of
AppT (ConT ((==) ''Entity -> True)) _innerType -> id
((ConT ((==) ''Maybe -> True)) `AppT` _inner) -> AppE (ConE 'Just)
(ConT _) -> id
_ -> error $ show x
_ -> id

-- | Generates the `sqlSelectColCount` declaration for an `SqlSelect` instance.
sqlMaybeSelectColCountDec :: RecordInfo -> Q Dec
Expand Down

0 comments on commit 2b8f2cf

Please sign in to comment.