Skip to content

Commit

Permalink
Always parenthesize arguments to not_
Browse files Browse the repository at this point in the history
  • Loading branch information
blujupiter32 committed Sep 26, 2023
1 parent bfaffab commit 19ca04f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,15 @@ countDistinct :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
countDistinct = countHelper "(DISTINCT " ")"

not_ :: SqlExpr (Value Bool) -> SqlExpr (Value Bool)
not_ v = ERaw noMeta $ \p info -> first ("NOT " <>) $ x p info
not_ v = ERaw noMeta (const $ first ("NOT " <>) . x)
where
x p info =
x info =
case v of
ERaw m f ->
if hasCompositeKeyMeta m then
throw (CompositeKeyErr NotError)
else
let (b, vals) = f Never info
in (parensM p b, vals)
f Parens info

(==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
(==.) = unsafeSqlBinOpComposite " = " " AND "
Expand Down

0 comments on commit 19ca04f

Please sign in to comment.