Maintainer | Brandon Chinn <brandonchinn178@gmail.com> |
---|---|
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Defines helper functions for writing SQL queries.
Synopsis
- commas :: Text -> [Text]
- uncommas :: [Text] -> Text
- uncommas' :: [Text] -> Text
- quote :: Text -> Text
- data MigrateSql = MigrateSql {
- sqlText :: Text
- sqlVals :: [PersistValue]
- executeSql :: MonadIO m => MigrateSql -> SqlPersistT m ()
- pureSql :: Text -> MigrateSql
- mapSql :: (Text -> Text) -> MigrateSql -> MigrateSql
- concatSql :: ([Text] -> Text) -> [MigrateSql] -> MigrateSql
Documentation
commas :: Text -> [Text] Source #
Split the given line by commas, ignoring commas within parentheses.
commas "a,b,c" == ["a", "b", "c"] commas "a,b,c (d,e),z" == ["a", "b", "c (d,e)", "z"] commas "a,b,c (d,e,(f,g)),z" == ["a", "b", "c (d,e,(f,g))", "z"]
uncommas' :: [Text] -> Text Source #
Join the given Text with commas separating each item and quoting them.
data MigrateSql Source #
A SQL query (with placeholders) and values to replace those placeholders.
MigrateSql | |
|
Instances
Show MigrateSql Source # | |
Defined in Database.Persist.Migration.Utils.Sql showsPrec :: Int -> MigrateSql -> ShowS # show :: MigrateSql -> String # showList :: [MigrateSql] -> ShowS # |
executeSql :: MonadIO m => MigrateSql -> SqlPersistT m () Source #
Execute a SQL query.
pureSql :: Text -> MigrateSql Source #
Create a MigrateSql from the given Text.
mapSql :: (Text -> Text) -> MigrateSql -> MigrateSql Source #
Map the SQL text with the given function.
concatSql :: ([Text] -> Text) -> [MigrateSql] -> MigrateSql Source #
Concatenate the given MigrateSql queries with the given combining function.