Skip to content

Commit ce2236d

Browse files
parsonsmattbitemyapp
authored andcommitted
uhhhh this passes all the tests?????
1 parent 9338cfd commit ce2236d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Database/Esqueleto/Internal/Internal.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,11 @@ v `notIn` e = ifNotEmptyList e True $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCo
634634
-- return person
635635
-- @
636636
exists :: SqlQuery () -> SqlExpr (Value Bool)
637-
exists = unsafeSqlFunction "EXISTS " . existsHelper
637+
exists = unsafeSqlFunctionNoParens "EXISTS " . existsHelper
638638

639639
-- | @NOT EXISTS@ operator.
640640
notExists :: SqlQuery () -> SqlExpr (Value Bool)
641-
notExists = unsafeSqlFunction "NOT EXISTS " . existsHelper
641+
notExists = unsafeSqlFunctionNoParens "NOT EXISTS " . existsHelper
642642

643643
-- | @SET@ clause used on @UPDATE@s. Note that while it's not
644644
-- a type error to use this function on a @SELECT@, it will
@@ -1716,6 +1716,14 @@ unsafeSqlValue v = ERaw Never $ const (v, mempty)
17161716
unsafeSqlFunction :: UnsafeSqlFunctionArgument a =>
17171717
TLB.Builder -> a -> SqlExpr (Value b)
17181718
unsafeSqlFunction name arg =
1719+
ERaw Never $ \info ->
1720+
let (argsTLB, argsVals) =
1721+
uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg
1722+
in (name <> parens (parens argsTLB), argsVals)
1723+
1724+
unsafeSqlFunctionNoParens :: UnsafeSqlFunctionArgument a =>
1725+
TLB.Builder -> a -> SqlExpr (Value b)
1726+
unsafeSqlFunctionNoParens name arg =
17191727
ERaw Never $ \info ->
17201728
let (argsTLB, argsVals) =
17211729
uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg

0 commit comments

Comments
 (0)