Skip to content

Commit

Permalink
Add inMany
Browse files Browse the repository at this point in the history
Closes #404

Closes #602
  • Loading branch information
tomjaguarpaw committed Aug 29, 2024
1 parent 64f91ae commit 86cf6b2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Opaleye/Operators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module Opaleye.Operators
, sqlLength
-- * Containment operators
, in_
, inMany
, inSelect
-- * JSON operators
, SqlIsJson
Expand Down Expand Up @@ -297,6 +298,19 @@ in_ fcas (Column a) = case NEL.nonEmpty (F.toList fcas) of
Nothing -> T.sqlBool False
Just xs -> Column $ HPQ.BinExpr HPQ.OpIn a (HPQ.ListExpr (fmap C.unColumn xs))

-- | @inMany@ is a generalization of 'in_' to values with multiple
-- fields. It is designed to be used in prefix form.
--
-- @inMany validUsers user@ checks whether @user@ is a valid user.
-- @inMany validUsers@ is a function which checks whether a user is a
-- valid user.
inMany ::
(F.Foldable f, D.Default O.EqPP fields fields) =>
f fields ->
fields ->
F.Field T.SqlBool
inMany xs x = ors (fmap (.=== x) xs)

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.10)

• Could not deduce ‘Functor f’ arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.10)

• Could not deduce ‘Functor f’ arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.0)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.8)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.8)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.0)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.10)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 8.10)

• Could not deduce (Functor f) arising from a use of ‘fmap’

Check failure on line 312 in src/Opaleye/Operators.hs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 9.2)

• Could not deduce (Functor f) arising from a use of ‘fmap’

-- | True if the first argument occurs amongst the rows of the second,
-- false otherwise.
--
Expand Down

0 comments on commit 86cf6b2

Please sign in to comment.