hasql-1.8.0.2: Fast PostgreSQL driver with a flexible mapping API
Safe HaskellNone
LanguageHaskell2010

Hasql.Session

Synopsis

Documentation

data Session a Source #

A batch of actions to be executed in the context of a database connection.

Instances

Instances details
MonadIO Session Source # 
Instance details

Defined in Hasql.Session.Core

Methods

liftIO :: IO a -> Session a #

Applicative Session Source # 
Instance details

Defined in Hasql.Session.Core

Methods

pure :: a -> Session a #

(<*>) :: Session (a -> b) -> Session a -> Session b #

liftA2 :: (a -> b -> c) -> Session a -> Session b -> Session c #

(*>) :: Session a -> Session b -> Session b #

(<*) :: Session a -> Session b -> Session a #

Functor Session Source # 
Instance details

Defined in Hasql.Session.Core

Methods

fmap :: (a -> b) -> Session a -> Session b #

(<$) :: a -> Session b -> Session a #

Monad Session Source # 
Instance details

Defined in Hasql.Session.Core

Methods

(>>=) :: Session a -> (a -> Session b) -> Session b #

(>>) :: Session a -> Session b -> Session b #

return :: a -> Session a #

MonadError SessionError Session Source # 
Instance details

Defined in Hasql.Session.Core

MonadReader Connection Session Source # 
Instance details

Defined in Hasql.Session.Core

sql :: ByteString -> Session () Source #

Possibly a multi-statement query, which however cannot be parameterized or prepared, nor can any results of it be collected.

statement :: params -> Statement params result -> Session result Source #

Execute a statement by providing parameters to it.

pipeline :: Pipeline result -> Session result Source #

Execute a pipeline.

Execution

run :: Session a -> Connection -> IO (Either SessionError a) Source #

Executes a bunch of commands on the provided connection.

Errors

data SessionError Source #

Error during execution of a session.

Constructors

QueryError

Error during the execution of a query. Comes packed with the query template and a textual representation of the provided params.

Fields

PipelineError

Error during the execution of a pipeline.

Fields

data CommandError Source #

An error of some command in the session.

Constructors

ClientError (Maybe ByteString)

An error on the client-side, with a message generated by the "libpq" library. Usually indicates problems with connection.

ResultError ResultError

Some error with a command result.

Instances

Instances details
Show CommandError Source # 
Instance details

Defined in Hasql.Errors

Eq CommandError Source # 
Instance details

Defined in Hasql.Errors

data ResultError Source #

An error with a command result.

Constructors

ServerError

An error reported by the DB.

Fields

  • ByteString

    Code. The SQLSTATE code for the error. It's recommended to use <http://hackage.haskell.org/package/postgresql-error-codes the "postgresql-error-codes" package> to work with those.

  • ByteString

    Message. The primary human-readable error message(typically one line). Always present.

  • (Maybe ByteString)

    Details. An optional secondary error message carrying more detail about the problem. Might run to multiple lines.

  • (Maybe ByteString)

    Hint. An optional suggestion on what to do about the problem. This is intended to differ from detail in that it offers advice (potentially inappropriate) rather than hard facts. Might run to multiple lines.

  • (Maybe Int)

    Position. Error cursor position as an index into the original statement string. Positions are measured in characters not bytes.

UnexpectedResult Text

The database returned an unexpected result. Indicates an improper statement or a schema mismatch.

RowError Int Int RowError

An error of the row reader, preceded by the indexes of the row and column.

UnexpectedAmountOfRows Int

An unexpected amount of rows.

Instances

Instances details
Show ResultError Source # 
Instance details

Defined in Hasql.Errors

Eq ResultError Source # 
Instance details

Defined in Hasql.Errors

data RowError Source #

An error during the decoding of a specific row.

Constructors

EndOfInput

Appears on the attempt to parse more columns than there are in the result.

UnexpectedNull

Appears on the attempt to parse a NULL as some value.

ValueError Text

Appears when a wrong value parser is used. Comes with the error details.

Instances

Instances details
Show RowError Source # 
Instance details

Defined in Hasql.Errors

Eq RowError Source # 
Instance details

Defined in Hasql.Errors