castString, SqlString for Maybe.
This commit is contained in:
parent
1cfe1b11df
commit
555faaeaac
@ -47,7 +47,7 @@ module Database.Esqueleto
|
|||||||
, random_, round_, ceiling_, floor_
|
, random_, round_, ceiling_, floor_
|
||||||
, min_, max_, sum_, avg_, castNum, castNumM
|
, min_, max_, sum_, avg_, castNum, castNumM
|
||||||
, coalesce, coalesceDefault
|
, coalesce, coalesceDefault
|
||||||
, lower_, like, ilike, (%), concat_, (++.)
|
, lower_, like, ilike, (%), concat_, (++.), castString
|
||||||
, subList_select, subList_selectDistinct, valList, justList
|
, subList_select, subList_selectDistinct, valList, justList
|
||||||
, in_, notIn, exists, notExists
|
, in_, notIn, exists, notExists
|
||||||
, set, (=.), (+=.), (-=.), (*=.), (/=.)
|
, set, (=.), (+=.), (-=.), (*=.), (/=.)
|
||||||
|
|||||||
@ -422,6 +422,17 @@ class (Functor query, Applicative query, Monad query) =>
|
|||||||
-- Haskell's '++' in order to avoid naming clash with '||.').
|
-- Haskell's '++' in order to avoid naming clash with '||.').
|
||||||
-- Supported by SQLite and PostgreSQL.
|
-- Supported by SQLite and PostgreSQL.
|
||||||
(++.) :: SqlString s => expr (Value s) -> expr (Value s) -> expr (Value s)
|
(++.) :: SqlString s => expr (Value s) -> expr (Value s) -> expr (Value s)
|
||||||
|
-- | Cast a string type into 'Text'. This function
|
||||||
|
-- is very useful if you want to use @newtype@s, or if you want
|
||||||
|
-- to apply functions such as 'like' to strings of different
|
||||||
|
-- types.
|
||||||
|
--
|
||||||
|
-- /Safety:/ This is a slightly unsafe function, especially if
|
||||||
|
-- you have defined your own instances of 'SqlString'. Also,
|
||||||
|
-- since 'Maybe' is an instance of 'SqlString', it's possible
|
||||||
|
-- to turn a nullable value into a non-nullable one. Avoid
|
||||||
|
-- using this function if possible.
|
||||||
|
castString :: (SqlString s, SqlString r) => expr (Value s) -> expr (Value r)
|
||||||
|
|
||||||
-- | Execute a subquery @SELECT@ in an expression. Returns a
|
-- | Execute a subquery @SELECT@ in an expression. Returns a
|
||||||
-- list of values.
|
-- list of values.
|
||||||
@ -800,6 +811,8 @@ instance SqlString B.ByteString where
|
|||||||
-- | /Since: 2.3.0/
|
-- | /Since: 2.3.0/
|
||||||
instance SqlString Html where
|
instance SqlString Html where
|
||||||
|
|
||||||
|
-- | /Since: 2.4.0/
|
||||||
|
instance SqlString a => SqlString (Maybe a) where
|
||||||
|
|
||||||
|
|
||||||
-- | @FROM@ clause: bring entities into scope.
|
-- | @FROM@ clause: bring entities into scope.
|
||||||
|
|||||||
@ -488,6 +488,7 @@ instance Esqueleto SqlQuery SqlExpr SqlBackend where
|
|||||||
(%) = unsafeSqlValue "'%'"
|
(%) = unsafeSqlValue "'%'"
|
||||||
concat_ = unsafeSqlFunction "CONCAT"
|
concat_ = unsafeSqlFunction "CONCAT"
|
||||||
(++.) = unsafeSqlBinOp " || "
|
(++.) = unsafeSqlBinOp " || "
|
||||||
|
castString = veryUnsafeCoerceSqlExprValue
|
||||||
|
|
||||||
subList_select = EList . sub_select
|
subList_select = EList . sub_select
|
||||||
subList_selectDistinct = subList_select . distinct
|
subList_selectDistinct = subList_select . distinct
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user