opaleye-0.6.7004.1: An SQL-generating DSL targeting PostgreSQL

Safe HaskellNone
LanguageHaskell2010

Opaleye.RunQuery

Contents

Description

This module will be deprecated in 0.7. Use Opaleye.RunSelect instead.

Synopsis

Documentation

runQuery :: Default FromFields fields haskells => Connection -> Select fields -> IO [haskells] Source #

Use runSelect instead. runQuery will be deprecated in 0.7.

runQueryFold :: Default FromFields fields haskells => Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b Source #

Use runSelectFold instead. runQueryFold will be deprecated in 0.7.

queryRunnerColumn :: (Column a' -> Column a) -> (b -> b') -> FromField a b -> FromField a' b' Source #

Use unsafeFromField instead. queryRunnerColumn will be deprecated in 0.7.

runQueryExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells] Source #

Use runSelectExplict instead. Will be deprecated in 0.7.

runQueryFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b Source #

Use runSelectFoldExplict instead. Will be deprecated in 0.7.

declareCursor :: Default FromFields fields haskells => Connection -> Select fields -> IO (Cursor haskells) Source #

Use declareCursor instead. Will be deprecated in 0.7.

declareCursorExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO (Cursor haskells) Source #

Use declareCursorExplicit instead. Will be deprecated in 0.7.

closeCursor :: Cursor fields -> IO () Source #

Use closeCursor instead. Will be deprecated in 0.7.

foldForward :: Cursor haskells -> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a) Source #

Use foldForward instead. Will be deprecated in 0.7.

prepareQuery :: FromFields fields haskells -> Select fields -> (Maybe Query, RowParser haskells) Source #

Deprecated: Will be removed in version 0.7

Datatypes

data Cursor haskells Source #

Cursor within a transaction.

data QueryRunner columns haskells Source #

A FromFields (or the old name QueryRunner) 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".

Instances
Profunctor FromFields Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

dimap :: (a -> b) -> (c -> d) -> FromFields b c -> FromFields a d #

lmap :: (a -> b) -> FromFields b c -> FromFields a c #

rmap :: (b -> c) -> FromFields a b -> FromFields a c #

(#.) :: Coercible c b => q b c -> FromFields a b -> FromFields a c #

(.#) :: Coercible b a => FromFields b c -> q a b -> FromFields a c #

ProductProfunctor FromFields Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

purePP :: b -> FromFields a b #

(****) :: FromFields a (b -> c) -> FromFields a b -> FromFields a c #

empty :: FromFields () () #

(***!) :: FromFields a b -> FromFields a' b' -> FromFields (a, a') (b, b') #

SumProfunctor FromFields Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

(+++!) :: FromFields a b -> FromFields a' b' -> FromFields (Either a a') (Either b b') #

DefaultFromField a b => Default FromFields (Column a) b Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

def :: FromFields (Column a) b #

Functor (FromFields c) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

fmap :: (a -> b) -> FromFields c a -> FromFields c b #

(<$) :: a -> FromFields c b -> FromFields c a #

Applicative (FromFields c) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

pure :: a -> FromFields c a #

(<*>) :: FromFields c (a -> b) -> FromFields c a -> FromFields c b #

liftA2 :: (a -> b -> c0) -> FromFields c a -> FromFields c b -> FromFields c c0 #

(*>) :: FromFields c a -> FromFields c b -> FromFields c b #

(<*) :: FromFields c a -> FromFields c b -> FromFields c a #

data QueryRunnerColumn pgType haskellType Source #

A FromField sqlType haskellType (or the old name, QueryRunnerColumn 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".

Instances
DefaultFromField sqlType haskellType => Default FromField sqlType haskellType Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

def :: FromField sqlType haskellType #

Functor (FromField u) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Methods

fmap :: (a -> b) -> FromField u a -> FromField u b #

(<$) :: a -> FromField u b -> FromField u a #

class QueryRunnerColumnDefault sqlType haskellType where Source #

(Note that a better name for this class would be DefaultFromField and it probably will have this name in version 0.7. When you see QueryRunnerColumnDefault please read DefaultFromField instead. That will probably make things easier to understand.)

A QueryRunnerColumnDefault sqlType haskellType represents the default way to turn a sqlType result from the database into a Haskell value of type haskellType.

"QueryRunnerColumnDefault sqlType haskellType" corresponds to postgresql-simple's "FromField 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.

  1. If you already have a postgresql-simple FromField instance for your haskellType, use fromPGSFromField. (This is how most of the built-in instances are defined.)
  2. If you don't have a postgresql-simple FromField instance, but you do have an Opaleye FromField value for the type it wraps use unsafeFromField if possible. See the documentation for unsafeFromField for an example.
  3. If you have a more complicated case, but not a FromField instance, write a FieldParser for your type and use fromPGSFieldParser. You can also add a FromField instance using this.

Minimal complete definition

queryRunnerColumnDefault | defaultFromField

Methods

queryRunnerColumnDefault :: FromField sqlType haskellType Source #

Do not use queryRunnerColumnDefault. It will be deprecated in version 0.7.

defaultFromField :: FromField sqlType haskellType Source #

Instances
QueryRunnerColumnDefault PGJsonb Value Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGJsonb String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGJson Value Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGJson String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGBytea ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGBytea ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGUuid UUID Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGTimestamptz UTCTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGTimestamptz ZonedTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGTimestamp LocalTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGTime TimeOfDay Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGText Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGText Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGText String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGNumeric Scientific Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGInt4 Int Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGInt4 Int32 Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGInt8 Int64 Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGFloat8 Double Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGDate Day Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGBool Bool Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGCitext (CI Text) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

QueryRunnerColumnDefault PGCitext (CI Text) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField a b => QueryRunnerColumnDefault (Nullable a) (Maybe b) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

(Typeable b, FromField b, DefaultFromField a b) => QueryRunnerColumnDefault (PGRange a) (PGRange b) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

(Typeable b, DefaultFromField a b) => QueryRunnerColumnDefault (PGArray a) [b] Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

Creating new QueryRunnerColumns

fieldQueryRunnerColumn :: FromField haskell => FromField pgType haskell Source #