Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data FromField pgType haskellType = QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType)
- type QueryRunnerColumn = FromField
- data FromFields columns haskells = QueryRunner (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Int)
- type QueryRunner = FromFields
- 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 DefaultFromField sqlType haskellType where
- queryRunnerColumnDefault :: FromField sqlType haskellType
- defaultFromField :: FromField sqlType haskellType
- type QueryRunnerColumnDefault = DefaultFromField
- arrayColumn :: Column (SqlArray a) -> Column a
- fromFieldArray :: Typeable h => FromField f h -> FromField (SqlArray 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
- prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells)
Documentation
data FromField pgType haskellType Source #
A FromField
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 QueryRunnerColumn = FromField Source #
data FromFields columns haskells Source #
A FromFields
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 QueryRunner = FromFields 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 DefaultFromField sqlType haskellType where Source #
A DefaultFromField
sqlType
haskellType
represents
the default way to turn a sqlType
result from the database into a
Haskell value of type haskellType
.
"DefaultFromField
sqlType
haskellType
" corresponds
to postgresql-simple's "FromField
haskellType
".
Creating an instance of DefaultFromField
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
DefaultFromField
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 #
Deprecated: Use defaultFromField instead. It will be removed in 0.8
defaultFromField :: FromField sqlType haskellType Source #
Instances
prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells Source #
Cursor within a transaction.
EmptyCursor | |
Cursor (RowParser haskells) Cursor |
prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells) Source #