Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data QueryRunnerColumn pgType haskellType = QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType)
- data QueryRunner columns haskells = QueryRunner (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Bool)
- fieldQueryRunnerColumn :: FromField haskell => QueryRunnerColumn pgType haskell
- fieldParserQueryRunnerColumn :: FieldParser haskell -> QueryRunnerColumn pgType haskell
- queryRunner :: QueryRunnerColumn a b -> QueryRunner (Column a) b
- queryRunnerColumnNullable :: QueryRunnerColumn a b -> QueryRunnerColumn (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 :: QueryRunner columns haskells -> columns -> RowParser haskells
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 (Unpackspec (Column pgType) ()) (FieldParser haskellType) |
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 (Unpackspec columns ()) (columns -> RowParser haskells) (columns -> Bool) | Have we actually requested any columns? If we asked for zero columns then the SQL generator will have to put a dummy 0 into the SELECT statement, since we can't select zero columns. In that case we have to make sure we read a single Int. |
fieldQueryRunnerColumn :: FromField haskell => QueryRunnerColumn pgType haskell Source #
fieldParserQueryRunnerColumn :: FieldParser haskell -> QueryRunnerColumn pgType haskell Source #
queryRunner :: QueryRunnerColumn a b -> QueryRunner (Column a) b Source #
queryRunnerColumnNullable :: QueryRunnerColumn a b -> QueryRunnerColumn (Nullable a) (Maybe 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
.
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
FromField
instance for yourhaskellType
, usefieldQueryRunnerColumn
. (This is how most of the built-in instances are defined.) - If you don't have a
FromField
instance, usequeryRunnerColumn
if possible. See the documentation forqueryRunnerColumn
for an example. - If you have a more complicated case, but not a
FromField
instance, write aFieldParser
for your type and usefieldParserQueryRunnerColumn
. You can also add aFromField
instance using this.
queryRunnerColumnDefault :: QueryRunnerColumn pgType haskellType Source #
prepareRowParser :: QueryRunner columns haskells -> columns -> RowParser haskells Source #