| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Opaleye.Internal.RunQuery
Synopsis
- data QueryRunnerColumn pgType haskellType = QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType)
- type FromField = QueryRunnerColumn
- data QueryRunner columns haskells = QueryRunner (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Bool)
- type FromFields = QueryRunner
- fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell
- fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell
- queryRunner :: FromField a b -> FromFields (Column a) b
- queryRunnerColumnNullable :: FromField a b -> FromField (Nullable a) (Maybe b)
- class QueryRunnerColumnDefault pgType haskellType where
- arrayColumn :: Column (PGArray a) -> Column a
- jsonFieldParser :: FieldParser String
- jsonbFieldParser :: FieldParser String
- jsonFieldTypeParser :: ByteString -> FieldParser String
- prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells
- data Cursor haskells
- = EmptyCursor
- | Cursor (RowParser haskells) Cursor
Documentation
data QueryRunnerColumn pgType haskellType Source #
A QueryRunnerColumn pgType haskellType encodes how to turn
a value of Postgres type pgType into a value of Haskell type
haskellType. For example a value of type QueryRunnerColumn
PGText String encodes how to turn a PGText result from the
database into a Haskell String.
"QueryRunnerColumn pgType haskellType" corresponds to
postgresql-simple's "FieldParser haskellType".
Constructors
| QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType) |
Instances
| QueryRunnerColumnDefault sqlType haskellType => Default FromField sqlType haskellType Source # | |
Defined in Opaleye.Internal.RunQuery | |
| Functor (FromField u) Source # | |
type FromField = QueryRunnerColumn Source #
data QueryRunner columns haskells Source #
A QueryRunner specifies how to convert Postgres values (columns)
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 QueryRunner instance.
"QueryRunner columns haskells" corresponds to
postgresql-simple's "RowParser haskells". "Default
QueryRunner columns haskells" corresponds to
postgresql-simple's "FromRow haskells".
Constructors
| QueryRunner (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Bool) |
Instances
type FromFields = QueryRunner Source #
fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell Source #
fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell Source #
queryRunner :: FromField a b -> FromFields (Column a) b Source #
class QueryRunnerColumnDefault pgType haskellType where Source #
A QueryRunnerColumnDefault pgType haskellType represents
the default way to turn a pgType result from the database into a
Haskell value of type haskellType.
"QueryRunnerColumnDefault pgType 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
FromFieldinstance for yourhaskellType, usefieldQueryRunnerColumn. (This is how most of the built-in instances are defined.) - If you don't have a
FromFieldinstance, usequeryRunnerColumnif possible. See the documentation forqueryRunnerColumnfor an example. - If you have a more complicated case, but not a
FromFieldinstance, write aFieldParserfor your type and usefieldParserQueryRunnerColumn. You can also add aFromFieldinstance using this.
Minimal complete definition
Methods
queryRunnerColumnDefault :: QueryRunnerColumn pgType haskellType Source #
Instances
prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells Source #