Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hasql.Postgres
Description
This module contains everything required to use "hasql" with Postgres. For information on how it should be used consult the "hasql" docs.
Please note that there is a few limitations inflicted by Postgres,
encoding which in the type system would seriously burden the API,
so it was decided to make it the user's responsibility
to make sure that certain conditions are satisfied during the runtime.
Particularly this concerns the CxValue
instances of
Maybe
, []
and Vector
.
For details consult the docs on those instances.
Documentation
A connection to PostgreSQL.
Instances
Cx Postgres | |
CxTx Postgres | |
CxValue Postgres Bool | Maps to |
CxValue Postgres Char | Maps to |
CxValue Postgres Double | Maps to |
CxValue Postgres Float | Maps to |
CxValue Postgres Int | Maps to |
CxValue Postgres Int8 | Maps to |
CxValue Postgres Int16 | Maps to |
CxValue Postgres Int32 | Maps to |
CxValue Postgres Int64 | Maps to |
CxValue Postgres Word | Maps to |
CxValue Postgres Word8 | Maps to |
CxValue Postgres Word16 | Maps to |
CxValue Postgres Word32 | Maps to |
CxValue Postgres Word64 | Maps to |
CxValue Postgres ByteString | Maps to |
CxValue Postgres Scientific | Maps to |
CxValue Postgres Text | Maps to |
CxValue Postgres UTCTime | Maps to NOTICE Postgres does not store the timezone information of |
CxValue Postgres Value | Maps to Only works for PostgreSQL versions >= 9.2. |
CxValue Postgres UUID | Maps to |
CxValue Postgres DiffTime | Maps to |
CxValue Postgres Day | Maps to |
CxValue Postgres TimeOfDay | Maps to |
CxValue Postgres LocalTime | Maps to |
CxValue Postgres Unknown | Maps to |
(Mapping a, ArrayMapping a) => CxValue Postgres [a] | Maps to Postgres arrays. LIMITATION 1 In multidimensional lists all rows of a dimension must have the same length. E.g., the following is a corrupt value: [[1,2], [3]] The following is a valid one: [[1,2], [3,4], [5,6]] LIMITATION 2
E.g., the following is a corrupt type: [Maybe [a]] However, both the first level list and the value are allowed to be wrapped in Maybe [[[Maybe a]]] NOTICE Also, please note that since |
Mapping a => CxValue Postgres (Maybe a) | Maps to the same type as the underlying value,
encoding LIMITATION Multilevel |
(Mapping a, ArrayMapping a) => CxValue Postgres (Vector a) | Maps to Postgres' arrays. Same rules as for the list instance apply. Consult its docs for details. |
CxValue Postgres (TimeOfDay, TimeZone) | Maps to Unlike with |
type CxError Postgres = CxError | |
type CxSettings Postgres = Settings | |
data ResultValue Postgres = ResultValue !Environment !(Maybe ByteString) | |
data StmtParam Postgres = StmtParam !Oid !(Environment -> Maybe ByteString) | |
type TxError Postgres = TxError |
Connection settings.
Constructors
ParamSettings ByteString Word16 ByteString ByteString ByteString | A host, a port, a user, a password and a database. |
StringSettings ByteString | All settings encoded in a single byte string according to the PostgreSQL format. |
Constructors
CantConnect (Maybe ByteString) | Impossible to connect. A clarification might be given in the attached byte string. |
UnsupportedVersion Int | Server is running an unsupported version of Postgres.
The parameter is the version in such a format,
where a value |
Constructors
NoResult !(Maybe ByteString) | Received no response from the database. |
ErroneousResult !ByteString !ByteString !(Maybe ByteString) !(Maybe ByteString) | An error reported by the DB. Code, message, details, hint.
|
UnexpectedResult !Text | The database returned an unexpected result. Indicates an improper statement or a schema mismatch. |
NotInTransaction | An attempt to perform an action, which requires a transaction context, without one. Currently it's only raised when trying to stream without establishing a transaction. |
A wrapper around a ByteString
,
which identifies the value with the PostgreSQL's "unknown" type,
thus leaving the choice of the type to Postgres.
The bytestring needs to be encoded according to the Postgres binary format
of the type it expects.
Essentially this is a low-level hook into the phases of encoding and decoding of values with custom codecs. The "postgresql-binary" library is your toolchain when dealing with this type.
Constructors
Unknown ByteString |