@@ -2,8 +2,8 @@
3module Rel8.Query.Exists
3module Rel8.Query.Exists
4 ( exists, inQuery
4 ( exists, inQuery
5− , whereExists, with, withBy
5+ , present, with, withBy
6− , whereNotExists, without, withoutBy
6+ , absent, without, withoutBy
@@ -25,7 +25,7 @@ import Rel8.Table.Maybe ( isJustTable )
26-- | Checks if a query returns at least one row.
26-- | Checks if a query returns at least one row.
27exists :: Query a -> Query (Expr Bool)
27exists :: Query a -> Query (Expr Bool)
28−exists = fmap isJustTable . optional . whereExists
28+exists = fmap isJustTable . optional . present
29-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it
29-- FIXME: change this when b7aacc07c6392654cae439fc3b997620c3aa7a87 makes it
30-- into a release of Opaleye
30-- into a release of Opaleye
@@ -34,23 +34,23 @@ inQuery :: EqTable a => a -> Query a -> Query (Expr Bool)
34inQuery a = exists . (>>= filter (a ==:))
34inQuery a = exists . (>>= filter (a ==:))
37−-- | Produce the empty query if the given query returns no rows. @whereExists@
37+-- | Produce the empty query if the given query returns no rows. @present@
38-- is equivalent to @WHERE EXISTS@ in SQL.
38-- is equivalent to @WHERE EXISTS@ in SQL.
39−whereExists :: Query a -> Query ()
39+present :: Query a -> Query ()
40−whereExists = mapOpaleye Opaleye.restrictExists
40+present = mapOpaleye Opaleye.restrictExists
43−-- | Produce the empty query if the given query returns rows. @whereNotExists@
43+-- | Produce the empty query if the given query returns rows. @absent@
44-- is equivalent to @WHERE NOT EXISTS@ in SQL.
44-- is equivalent to @WHERE NOT EXISTS@ in SQL.
45−whereNotExists :: Query a -> Query ()
45+absent :: Query a -> Query ()
46−whereNotExists = mapOpaleye Opaleye.restrictNotExists
46+absent = mapOpaleye Opaleye.restrictNotExists
49-- | @with@ is similar to 'filter', but allows the predicate to be a full query.
49-- | @with@ is similar to 'filter', but allows the predicate to be a full query.
51−-- @with f a = a <$ whereExists (f a)@, but this form matches 'filter'.
51+-- @with f a = a <$ present (f a)@, but this form matches 'filter'.
52with :: (a -> Query b) -> a -> Query a
52with :: (a -> Query b) -> a -> Query a
53−with f a = a <$ whereExists (f a)
53+with f a = a <$ present (f a)
56-- | Like @with@, but with a custom membership test.
56-- | Like @with@, but with a custom membership test.
@@ -60,7 +60,7 @@ withBy predicate bs = with $ \a -> bs >>= filter (predicate a)
61-- | Filter rows where @a -> Query b@ yields no rows.
61-- | Filter rows where @a -> Query b@ yields no rows.
62without :: (a -> Query b) -> a -> Query a
62without :: (a -> Query b) -> a -> Query a
63−without f a = a <$ whereNotExists (f a)
63+without f a = a <$ absent (f a)
66-- | Like @without@, but with a custom membership test.
66-- | Like @without@, but with a custom membership test.