| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Opaleye.Internal.RunQuery
Synopsis
- newtype FromField sqlType haskellType = FromField (FieldParser haskellType)
- data FromFields fields haskells = FromFields (Unpackspec fields ()) (fields -> RowParser haskells) (fields -> Int)
- fromPGSFromField :: FromField haskell => FromField pgType haskell
- fromPGSFieldParser :: FieldParser haskell -> FromField pgType haskell
- fromFields :: FromField a b -> FromFields (Field a) b
- fieldParserFromFields :: FieldParser haskells -> FromFields (Field_ n a) haskells
- fromFieldsNullable :: FromField a b -> FromFields (FieldNullable a) (Maybe b)
- unsafeFromFieldRaw :: FromField a (Field, Maybe ByteString)
- class DefaultFromField sqlType haskellType where
- defaultFromField :: FromField sqlType haskellType
- fromFieldArray :: Typeable h => FromField f h -> FromField (SqlArray_ NonNullable f) [h]
- fromFieldArrayNullable :: Typeable h => FromField f h -> FromField (SqlArray_ 'Nullable f) [Maybe h]
- fromFieldRange :: Typeable b => FromField a b -> FromField (SqlRange a) (PGRange b)
- jsonFieldParser :: FieldParser String
- jsonbFieldParser :: FieldParser String
- jsonFieldTextParser :: FieldParser Text
- jsonbFieldTextParser :: FieldParser Text
- jsonFieldLazyTextParser :: FieldParser Text
- jsonbFieldLazyTextParser :: FieldParser Text
- jsonFieldByteParser :: FieldParser ByteString
- jsonbFieldByteParser :: FieldParser ByteString
- jsonFieldLazyByteParser :: FieldParser ByteString
- jsonbFieldLazyByteParser :: FieldParser ByteString
- jsonFieldTypeByteParser :: ByteString -> FieldParser ByteString
- withJsonByteStringParser :: (ByteString -> b) -> ByteString -> FieldParser b
- jsonFieldTypeParser :: ByteString -> FieldParser String
- jsonFieldTypeTextParser :: ByteString -> FieldParser Text
- jsonFieldTypeLazyTextParser :: ByteString -> FieldParser Text
- jsonFieldTypeLazyByteParser :: ByteString -> FieldParser ByteString
- 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
newtype FromField sqlType 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".
Constructors
| FromField (FieldParser haskellType) |
Instances
data FromFields fields haskells Source #
A FromFields
specifies how to convert Postgres values (fields)
into Haskell values (haskells). Most likely you will never need
to create one 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 fields haskells" corresponds to
postgresql-simple's "FromRow haskells".
Constructors
| FromFields (Unpackspec fields ()) (fields -> RowParser haskells) (fields -> Int) |
Instances
fromPGSFromField :: FromField haskell => FromField pgType haskell Source #
fromPGSFieldParser :: FieldParser haskell -> FromField pgType haskell Source #
fromFields :: FromField a b -> FromFields (Field a) b Source #
fieldParserFromFields :: FieldParser haskells -> FromFields (Field_ n a) haskells Source #
fromFieldsNullable :: FromField a b -> FromFields (FieldNullable a) (Maybe b) Source #
unsafeFromFieldRaw :: FromField a (Field, Maybe ByteString) 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
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.
Methods
defaultFromField :: FromField sqlType haskellType Source #
Instances
fromFieldArray :: Typeable h => FromField f h -> FromField (SqlArray_ NonNullable f) [h] Source #
fromFieldArrayNullable :: Typeable h => FromField f h -> FromField (SqlArray_ 'Nullable f) [Maybe h] Source #
withJsonByteStringParser :: (ByteString -> b) -> ByteString -> FieldParser b Source #
prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells Source #
Cursor within a transaction.
Constructors
| EmptyCursor | |
| Cursor (RowParser haskells) Cursor |
prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells) Source #