| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Opaleye.RunQuery
Description
This module will be deprecated in 0.7. Use Opaleye.RunSelect instead.
Synopsis
- runQuery :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells]
- runQueryFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
- queryRunnerColumn :: (Column a' -> Column a) -> (b -> b') -> FromField a b -> FromField a' b'
- runQueryExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells]
- runQueryFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
- declareCursor :: Default FromFields fields haskells => Connection -> Select fields -> IO (Cursor haskells)
- declareCursorExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO (Cursor haskells)
- closeCursor :: Cursor fields -> IO ()
- foldForward :: Cursor haskells -> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a)
- prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells)
- data Cursor haskells
- type FromFields = QueryRunner
- type FromField = QueryRunnerColumn
- data QueryRunner columns haskells
- data QueryRunnerColumn pgType haskellType
- class QueryRunnerColumnDefault sqlType haskellType where
- queryRunnerColumnDefault :: FromField sqlType haskellType
- defaultFromField :: FromField sqlType haskellType
- fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell
- fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell
Documentation
runQuery :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells] Source #
Use runSelect instead. runQuery will be
deprecated in 0.7.
runQueryFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b Source #
Use runSelectFold instead. runQueryFold
will be deprecated in 0.7.
queryRunnerColumn :: (Column a' -> Column a) -> (b -> b') -> FromField a b -> FromField a' b' Source #
Use unsafeFromField instead.
queryRunnerColumn will be deprecated in 0.7.
runQueryExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells] Source #
Use runSelectExplict instead. Will be
deprecated in 0.7.
runQueryFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b Source #
Use runSelectFoldExplict instead. Will be
deprecated in 0.7.
declareCursor :: Default FromFields fields haskells => Connection -> Select fields -> IO (Cursor haskells) Source #
Use declareCursor instead. Will be
deprecated in 0.7.
declareCursorExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO (Cursor haskells) Source #
Use declareCursorExplicit instead. Will be
deprecated in 0.7.
closeCursor :: Cursor fields -> IO () Source #
Use closeCursor instead. Will be
deprecated in 0.7.
foldForward :: Cursor haskells -> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a) Source #
Use foldForward instead. Will be
deprecated in 0.7.
prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells) Source #
Deprecated: Will be removed in version 0.7
Datatypes
type FromFields = QueryRunner Source #
type FromField = QueryRunnerColumn Source #
data QueryRunner columns haskells Source #
A FromFields (or the old name QueryRunner)
specifies how to convert Postgres values (fields)
into Haskell values (haskells). Most likely you will never need
to create on of these or handle one directly. It will be provided
for you by the Default FromFields instance.
"FromFields fields haskells" corresponds to
postgresql-simple's "RowParser haskells". "Default
FromFields columns haskells" corresponds to
postgresql-simple's "FromRow haskells".
Instances
data QueryRunnerColumn pgType haskellType Source #
A FromField sqlType haskellType
(or the old name, QueryRunnerColumn sqlType haskellType)
encodes how to turn
a value of Postgres type sqlType into a value of Haskell type
haskellType. For example a value of type FromField
SqlText String encodes how to turn a SqlText result from the
database into a Haskell String.
"FromField sqlType haskellType" corresponds to
postgresql-simple's "FieldParser haskellType".
Instances
class QueryRunnerColumnDefault sqlType haskellType where Source #
(Note that a better name for this class would be
DefaultFromField and it probably will have this name in version
0.7. When you see QueryRunnerColumnDefault please read
DefaultFromField instead. That will probably make things easier
to understand.)
A QueryRunnerColumnDefault sqlType haskellType represents
the default way to turn a sqlType result from the database into a
Haskell value of type haskellType.
"QueryRunnerColumnDefault sqlType haskellType" corresponds
to postgresql-simple's "FromField haskellType".
Creating an instance of QueryRunnerColumnDefault for your own types is
necessary for retrieving those types from the database.
You should use one of the three methods below for writing a
QueryRunnerColumnDefault instance.
- If you already have a postgresql-simple
FromFieldinstance for yourhaskellType, usefromPGSFromField. (This is how most of the built-in instances are defined.) - If you don't have a postgresql-simple
FromFieldinstance, but you do have an OpaleyeFromFieldvalue for the type it wraps useunsafeFromFieldif possible. See the documentation forunsafeFromFieldfor an example. - If you have a more complicated case, but not a
FromFieldinstance, write aFieldParserfor your type and usefromPGSFieldParser. You can also add aFromFieldinstance using this.
Minimal complete definition
Methods
queryRunnerColumnDefault :: FromField sqlType haskellType Source #
Do not use queryRunnerColumnDefault. It will be deprecated
in version 0.7.
defaultFromField :: FromField sqlType haskellType Source #
Instances
Creating new QueryRunnerColumns
fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell Source #
fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell Source #