persistent-1.1.5.1: Type-safe, multi-backend data serialization.

Safe Haskell | None

Database.Persist.GenericSql.Internal

Description

Code that is only needed for writing GenericSql backends.

Synopsis

- data Connection = Connection {
  - prepare :: Text -> IO Statement
  - insertSql :: DBName -> [DBName] -> DBName -> InsertSqlResult
  - stmtMap :: IORef (Map Text Statement)
  - close :: IO ()
  - migrateSql :: forall v. PersistEntity v => [EntityDef] -> (Text -> IO Statement) -> v -> IO (Either [Text] [(Bool, Text)])
  - begin :: (Text -> IO Statement) -> IO ()
  - commitC :: (Text -> IO Statement) -> IO ()
  - rollbackC :: (Text -> IO Statement) -> IO ()
  - escapeName :: DBName -> Text
  - noLimit :: Text
  }
- data Statement = Statement {
  - finalize :: IO ()
  - reset :: IO ()
  - execute :: [PersistValue] -> IO Int64
  - withStmt :: forall m. MonadResource m => [PersistValue] -> Source m [PersistValue]
  }
- withSqlConn :: (MonadIO m, MonadBaseControl IO m) => IO Connection -> (Connection -> m a) -> m a
- withSqlPool :: MonadIO m => IO Connection -> Int -> (Pool Connection -> m a) -> m a
- createSqlPool :: MonadIO m => IO Connection -> Int -> m (Pool Connection)
- mkColumns :: PersistEntity val => [EntityDef] -> val -> ([Column], [UniqueDef])
- data Column = Column {
  - cName :: DBName
  - cNull :: Bool
  - cType :: SqlType
  - cDefault :: Maybe Text
  - cMaxLen :: Maybe Integer
  - cReference :: Maybe (DBName, DBName)
  }
- logSQL :: Q Exp
- data InsertSqlResult
  - = ISRSingle Text
  - | ISRInsertGet Text Text

# Documentation

data Connection

Constructors

Connection |
Fields prepare :: Text -> IO Statement table name, column names, id name, either 1 or 2 statements to run insertSql :: DBName -> [DBName] -> DBName -> InsertSqlResult stmtMap :: IORef (Map Text Statement) close :: IO () migrateSql :: forall v. PersistEntity v => [EntityDef] -> (Text -> IO Statement) -> v -> IO (Either [Text] [(Bool, Text)]) begin :: (Text -> IO Statement) -> IO () commitC :: (Text -> IO Statement) -> IO () rollbackC :: (Text -> IO Statement) -> IO () escapeName :: DBName -> Text noLimit :: Text

data Statement

Constructors

Statement |
Fields finalize :: IO () reset :: IO () execute :: [PersistValue] -> IO Int64 withStmt :: forall m. MonadResource m => [PersistValue] -> Source m [PersistValue]

withSqlConn :: (MonadIO m, MonadBaseControl IO m) => IO Connection -> (Connection -> m a) -> m a

withSqlPool

Arguments

:: MonadIO m |
=> IO Connection | create a new connection
-> Int | connection count
-> (Pool Connection -> m a) |
-> m a |

createSqlPool :: MonadIO m => IO Connection -> Int -> m (Pool Connection)

mkColumns :: PersistEntity val => [EntityDef] -> val -> ([Column], [UniqueDef])

Create the list of columns for the given entity.

data Column

Constructors

Column |
Fields cName :: DBName cNull :: Bool cType :: SqlType cDefault :: Maybe Text cMaxLen :: Maybe Integer cReference :: Maybe (DBName, DBName)

Instances

Eq Column |
Ord Column |
Show Column |

logSQL :: Q Exp

data InsertSqlResult

Constructors

ISRSingle Text |
ISRInsertGet Text Text |