diff --git a/src/Opaleye/Operators.hs b/src/Opaleye/Operators.hs index 1ef5ff4d..89209ca0 100644 --- a/src/Opaleye/Operators.hs +++ b/src/Opaleye/Operators.hs @@ -58,6 +58,7 @@ module Opaleye.Operators , sqlLength -- * Containment operators , in_ + , inMany , inSelect -- * JSON operators , SqlIsJson @@ -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) + -- | True if the first argument occurs amongst the rows of the second, -- false otherwise. --