change coalesceDefault argument order
This commit is contained in:
parent
e735378f90
commit
22f03c2e39
@ -263,7 +263,7 @@ class (Functor query, Applicative query, Monad query) =>
|
||||
-- | Like @coalesce@, but takes a non-nullable expression
|
||||
-- placed at the end of the expression list, which guarantees
|
||||
-- a non-NULL result.
|
||||
coalesceDefault :: PersistField a => expr (Value a) -> [expr (Value (Maybe a))] -> expr (Value a)
|
||||
coalesceDefault :: PersistField a => [expr (Value (Maybe a))] -> expr (Value a) -> expr (Value a)
|
||||
|
||||
-- | @LIKE@ operator.
|
||||
like :: (PersistField s, IsString s) => expr (Value s) -> expr (Value s) -> expr (Value Bool)
|
||||
|
||||
@ -373,8 +373,8 @@ instance Esqueleto SqlQuery SqlExpr SqlBackend where
|
||||
min_ = unsafeSqlFunction "MIN"
|
||||
max_ = unsafeSqlFunction "MAX"
|
||||
|
||||
coalesce = unsafeSqlFunction "COALESCE"
|
||||
coalesceDefault def_expr exprs = unsafeSqlFunction "COALESCE" (exprs ++ [just def_expr])
|
||||
coalesce = unsafeSqlFunction "COALESCE"
|
||||
coalesceDefault exprs = unsafeSqlFunction "COALESCE" . (exprs ++) . return . just
|
||||
|
||||
like = unsafeSqlBinOp " LIKE "
|
||||
(%) = unsafeSqlValue "'%'"
|
||||
|
||||
@ -582,7 +582,7 @@ main = do
|
||||
ret2 <- select $
|
||||
from $ \p -> do
|
||||
orderBy [asc (p ^. PersonId)]
|
||||
return (coalesceDefault (p ^. PersonFavNum) [p ^. PersonAge, p ^. PersonWeight])
|
||||
return (coalesceDefault [p ^. PersonAge, p ^. PersonWeight] (p ^. PersonFavNum))
|
||||
liftIO $ ret2 `shouldBe` [ Value (36 :: Int)
|
||||
, Value 37
|
||||
, Value 17
|
||||
|
||||
Loading…
Reference in New Issue
Block a user