Skip to content

Commit

Permalink
uhhhh this passes all the tests?????
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt committed Jun 17, 2019
1 parent ca44655 commit e6254a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Database/Esqueleto/Internal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,11 @@ v `notIn` e = ifNotEmptyList e True $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCo
-- return person
-- @
exists :: SqlQuery () -> SqlExpr (Value Bool)
exists = unsafeSqlFunction "EXISTS " . existsHelper
exists = unsafeSqlFunctionNoParens "EXISTS " . existsHelper

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

-- | @SET@ clause used on @UPDATE@s. Note that while it's not
-- a type error to use this function on a @SELECT@, it will
Expand Down Expand Up @@ -1709,6 +1709,14 @@ unsafeSqlValue v = ERaw Never $ const (v, mempty)
unsafeSqlFunction :: UnsafeSqlFunctionArgument a =>
TLB.Builder -> a -> SqlExpr (Value b)
unsafeSqlFunction name arg =
ERaw Never $ \info ->
let (argsTLB, argsVals) =
uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg
in (name <> parens (parens argsTLB), argsVals)

unsafeSqlFunctionNoParens :: UnsafeSqlFunctionArgument a =>
TLB.Builder -> a -> SqlExpr (Value b)
unsafeSqlFunctionNoParens name arg =
ERaw Never $ \info ->
let (argsTLB, argsVals) =
uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg
Expand Down

0 comments on commit e6254a4

Please sign in to comment.