diff --git a/src/Database/Esqueleto/PostgreSQL.hs b/src/Database/Esqueleto/PostgreSQL.hs index 5e5e4ed..db8209b 100644 --- a/src/Database/Esqueleto/PostgreSQL.hs +++ b/src/Database/Esqueleto/PostgreSQL.hs @@ -6,6 +6,7 @@ module Database.Esqueleto.PostgreSQL ( arrayAgg , stringAgg + , chr ) where import Data.String (IsString) @@ -32,3 +33,12 @@ stringAgg -> SqlExpr (Value s) -- ^ Delimiter. -> SqlExpr (Value s) -- ^ Concatenation. 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" diff --git a/test/Test.hs b/test/Test.hs index 5093359..acf2c96 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -1356,8 +1356,12 @@ main = do from $ \p -> do return (EP.stringAgg (p ^. PersonName) (val " ")) 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 ----------------------------------------------------------------------