New justList function.
This commit is contained in:
parent
9dbdcb53fa
commit
871708987d
@ -48,7 +48,7 @@ module Database.Esqueleto
|
|||||||
, min_, max_, sum_, avg_, castNum, castNumM
|
, min_, max_, sum_, avg_, castNum, castNumM
|
||||||
, coalesce, coalesceDefault
|
, coalesce, coalesceDefault
|
||||||
, lower_, like, ilike, (%), concat_, (++.)
|
, lower_, like, ilike, (%), concat_, (++.)
|
||||||
, subList_select, subList_selectDistinct, valList
|
, subList_select, subList_selectDistinct, valList, justList
|
||||||
, in_, notIn, exists, notExists
|
, in_, notIn, exists, notExists
|
||||||
, set, (=.), (+=.), (-=.), (*=.), (/=.)
|
, set, (=.), (+=.), (-=.), (*=.), (/=.)
|
||||||
, case_ )
|
, case_ )
|
||||||
|
|||||||
@ -427,6 +427,13 @@ class (Functor query, Applicative query, Monad query) =>
|
|||||||
-- | Lift a list of constant value from Haskell-land to the query.
|
-- | Lift a list of constant value from Haskell-land to the query.
|
||||||
valList :: PersistField typ => [typ] -> expr (ValueList typ)
|
valList :: PersistField typ => [typ] -> expr (ValueList typ)
|
||||||
|
|
||||||
|
-- | Same as 'just' but for 'ValueList'. Most of the time you
|
||||||
|
-- won't need it, though, because you can use 'just' from
|
||||||
|
-- inside 'subList_select' or 'Just' from inside 'valList'.
|
||||||
|
--
|
||||||
|
-- /Since: 2.2.12/
|
||||||
|
justList :: expr (ValueList typ) -> expr (ValueList (Maybe typ))
|
||||||
|
|
||||||
-- | @IN@ operator.
|
-- | @IN@ operator.
|
||||||
in_ :: PersistField typ => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)
|
in_ :: PersistField typ => expr (Value typ) -> expr (ValueList typ) -> expr (Value Bool)
|
||||||
|
|
||||||
|
|||||||
@ -496,6 +496,9 @@ instance Esqueleto SqlQuery SqlExpr SqlBackend where
|
|||||||
valList vals = EList $ ERaw Parens $ const ( uncommas ("?" <$ vals)
|
valList vals = EList $ ERaw Parens $ const ( uncommas ("?" <$ vals)
|
||||||
, map toPersistValue vals )
|
, map toPersistValue vals )
|
||||||
|
|
||||||
|
justList EEmptyList = EEmptyList
|
||||||
|
justList (EList v) = EList (just v)
|
||||||
|
|
||||||
v `in_` e = ifNotEmptyList e False $ unsafeSqlBinOp " IN " v (veryUnsafeCoerceSqlExprValueList e)
|
v `in_` e = ifNotEmptyList e False $ unsafeSqlBinOp " IN " v (veryUnsafeCoerceSqlExprValueList e)
|
||||||
v `notIn` e = ifNotEmptyList e True $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCoerceSqlExprValueList e)
|
v `notIn` e = ifNotEmptyList e True $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCoerceSqlExprValueList e)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user