Adding chr to the list of Postgresql functions.
This commit is contained in:
parent
22ba061e8b
commit
fa1d1c8887
@ -6,6 +6,7 @@
|
|||||||
module Database.Esqueleto.PostgreSQL
|
module Database.Esqueleto.PostgreSQL
|
||||||
( arrayAgg
|
( arrayAgg
|
||||||
, stringAgg
|
, stringAgg
|
||||||
|
, chr
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.String (IsString)
|
import Data.String (IsString)
|
||||||
@ -32,3 +33,12 @@ stringAgg
|
|||||||
-> SqlExpr (Value s) -- ^ Delimiter.
|
-> SqlExpr (Value s) -- ^ Delimiter.
|
||||||
-> SqlExpr (Value s) -- ^ Concatenation.
|
-> SqlExpr (Value s) -- ^ Concatenation.
|
||||||
stringAgg expr delim = unsafeSqlFunction "string_agg" (expr, delim)
|
stringAgg expr delim = unsafeSqlFunction "string_agg" (expr, delim)
|
||||||
|
|
||||||
|
|
||||||
|
-- | (@chr@) Translate the given integer to a character. (Note the result will
|
||||||
|
-- depend on the character set of your database.)
|
||||||
|
--
|
||||||
|
-- /Since: 2.2.11/
|
||||||
|
chr :: IsString s
|
||||||
|
=> SqlExpr (Value Int) -> SqlExpr (Value s)
|
||||||
|
chr = unsafeSqlFunction "chr"
|
||||||
|
|||||||
@ -1356,8 +1356,12 @@ main = do
|
|||||||
from $ \p -> do
|
from $ \p -> do
|
||||||
return (EP.stringAgg (p ^. PersonName) (val " "))
|
return (EP.stringAgg (p ^. PersonName) (val " "))
|
||||||
liftIO $ L.sort (words ret) `shouldBe` L.sort (map personName people)
|
liftIO $ L.sort (words ret) `shouldBe` L.sort (map personName people)
|
||||||
#endif
|
|
||||||
|
|
||||||
|
it "chr looks sane" $
|
||||||
|
run $ do
|
||||||
|
[Value (ret :: String)] <- select $ return (EP.chr (val 65))
|
||||||
|
liftIO $ ret `shouldBe` "A"
|
||||||
|
#endif
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user