Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 -> Int)
- type FromFields = QueryRunner
- fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell
- fromPGSFromField :: FromField haskell => FromField pgType haskell
- fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell
- fromPGSFieldParser :: FieldParser haskell -> FromField pgType haskell
- queryRunner :: FromField a b -> FromFields (Column a) b
- queryRunnerColumnNullable :: FromField a b -> FromField (Nullable a) (Maybe b)
- class QueryRunnerColumnDefault sqlType haskellType where
- queryRunnerColumnDefault :: FromField sqlType haskellType
- defaultFromField :: FromField sqlType haskellType
- type DefaultFromField = QueryRunnerColumnDefault
- arrayColumn :: Column (PGArray a) -> Column a
- fromFieldArray :: Typeable h => FromField f h -> FromField (PGArray f) [h]
- 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 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
".
QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType) |
Instances
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
".
QueryRunner (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Int) |
Instances
type FromFields = QueryRunner Source #
fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell Source #
fromPGSFromField :: FromField haskell => FromField pgType haskell Source #
fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell Source #
fromPGSFieldParser :: FieldParser haskell -> FromField pgType haskell Source #
queryRunner :: FromField a b -> FromFields (Column a) b Source #
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
FromField
instance for yourhaskellType
, usefromPGSFromField
. (This is how most of the built-in instances are defined.) - If you don't have a postgresql-simple
FromField
instance, but you do have an OpaleyeFromField
value for the type it wraps useunsafeFromField
if possible. See the documentation forunsafeFromField
for an example. - If you have a more complicated case, but not a
FromField
instance, write aFieldParser
for your type and usefromPGSFieldParser
. You can also add aFromField
instance using this.
queryRunnerColumnDefault :: FromField sqlType haskellType Source #
Do not use queryRunnerColumnDefault
. It will be deprecated
in version 0.7.
defaultFromField :: FromField sqlType haskellType Source #
Instances
prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells Source #