@@ -93,13 +93,6 @@ module Squeal.PostgreSQL.Query
94 , GroupByClause (..)
94 , GroupByClause (..)
95 , HavingClause (..)
95 , HavingClause (..)
96− -- * Subquery Expressions
105import Control.DeepSeq
98import Control.DeepSeq
@@ -1093,90 +1086,6 @@ instance RenderSQL (HavingClause outer commons grp schemas params from) where
1093 Having conditions ->
1086 Having conditions ->
1094 " HAVING" <+> commaSeparated (renderSQL <$> conditions)
1087 " HAVING" <+> commaSeparated (renderSQL <$> conditions)
1097−The argument of `exists` is an arbitrary subquery. The subquery is evaluated
1098−to determine whether it returns any rows. If it returns at least one row,
1099−the result of `exists` is `true`; if the subquery returns no rows,
1100−the result of `exists` is `false`.
1102−The subquery can refer to variables from the surrounding query,
1103−which will act as constants during any one evaluation of the subquery.
1105−The subquery will generally only be executed long enough to determine whether
1106−at least one row is returned, not all the way to completion.
1109− :: Query (Join outer from) commons schemas params row
1110− -> Condition outer commons grp schemas params from
1111−exists query = UnsafeExpression $ "EXISTS" <+> parenthesized (renderSQL query)
1114−The right-hand side is a parenthesized subquery, which must return
1115−exactly one column. The left-hand expression is evaluated and compared to each
1116−row of the subquery result using the given `Operator`,
1117−which must yield a Boolean result. The result of `subAll` is `true`
1118−if all rows yield true (including the case where the subquery returns no rows).
1119−The result is `false` if any `false` result is found.
1120−The result is `null_` if no comparison with a subquery row returns `false`,
1121−and at least one comparison returns `null_`.
1123−>>> printSQL $ subAll true (.==) (values_ (true `as` #foo))
1124−(TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo")))
1127− :: Expression outer commons grp schemas params from ty1 -- ^ expression
1128− -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1129− -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1130− -> Condition outer commons grp schemas params from
1131−subAll expr (?) qry = expr ?
1132− (UnsafeExpression $ "ALL" <+> parenthesized (renderSQL qry))
1135−The right-hand side is a parenthesized subquery, which must return exactly one column.
1136−The left-hand expression is evaluated and compared to each row of the subquery result
1137−using the given `Operator`, which must yield a Boolean result. The result of `subAny` is `true`
1138−if any `true` result is obtained. The result is `false` if no true result is found
1139−(including the case where the subquery returns no rows).
1141−>>> printSQL $ subAll "foo" like (values_ ("foobar" `as` #foo))
1142−(E'foo' LIKE ALL (SELECT * FROM (VALUES (E'foobar')) AS t ("foo")))
1145− :: Expression outer commons grp schemas params from ty1 -- ^ expression
1146− -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1147− -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1148− -> Condition outer commons grp schemas params from
1149−subAny expr (?) qry = expr ?
1150− (UnsafeExpression $ "ANY" <+> parenthesized (renderSQL qry))
1153−The result is `true` if the left-hand expression's result is equal
1154−to any of the right-hand expressions.
1156−>>> printSQL $ true `in_` [true, false, null_]
1157−TRUE IN (TRUE, FALSE, NULL)
1160− :: Expression outer commons grp schemas params from ty -- ^ expression
1161− -> [Expression outer commons grp schemas params from ty]
1162− -> Condition outer commons grp schemas params from
1163−expr `in_` exprs = UnsafeExpression $ renderSQL expr <+> "IN"
1164− <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1167−The result is `true` if the left-hand expression's result is not equal
1168−to any of the right-hand expressions.
1170−>>> printSQL $ true `notIn` [false, null_]
1171−TRUE NOT IN (FALSE, NULL)
1174− :: Expression outer commons grp schemas params from ty -- ^ expression
1175− -> [Expression outer commons grp schemas params from ty]
1176− -> Condition outer commons grp schemas params from
1177−expr `notIn` exprs = UnsafeExpression $ renderSQL expr <+> "NOT IN"
1178− <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1180-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.
1089-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.
1181data CommonTableExpression statement
1090data CommonTableExpression statement
1182 (schemas :: SchemasType)
1091 (schemas :: SchemasType)