opaleye-0.5.3.0: An SQL-generating DSL targeting PostgreSQL

Safe HaskellNone
LanguageHaskell2010

Opaleye.Internal.RunQuery

Synopsis

Documentation

data QueryRunnerColumn pgType haskellType #

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.

Constructors

QueryRunnerColumn (Unpackspec (Column pgType) ()) (FieldParser haskellType) 

Instances

data QueryRunner columns haskells #

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.

Constructors

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.

Instances

SumProfunctor QueryRunner # 

Methods

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

ProductProfunctor QueryRunner # 

Methods

purePP :: b -> QueryRunner a b #

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

empty :: QueryRunner () () #

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

Profunctor QueryRunner # 

Methods

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

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

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

(#.) :: Coercible * c b => (b -> c) -> QueryRunner a b -> QueryRunner a c #

(.#) :: Coercible * b a => QueryRunner b c -> (a -> b) -> QueryRunner a c #

QueryRunnerColumnDefault a b => Default QueryRunner (Column a) b # 

Methods

def :: QueryRunner (Column a) b #

Functor (QueryRunner c) # 

Methods

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

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

Applicative (QueryRunner c) # 

Methods

pure :: a -> QueryRunner c a #

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

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

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

class QueryRunnerColumnDefault pgType haskellType where #

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.

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

Minimal complete definition

queryRunnerColumnDefault

Methods

queryRunnerColumnDefault :: QueryRunnerColumn pgType haskellType #

Instances

QueryRunnerColumnDefault PGJsonb String # 
QueryRunnerColumnDefault PGJsonb Value # 
QueryRunnerColumnDefault PGJson String # 
QueryRunnerColumnDefault PGJson Value # 
QueryRunnerColumnDefault PGBytea ByteString # 
QueryRunnerColumnDefault PGBytea ByteString # 
QueryRunnerColumnDefault PGUuid UUID # 
QueryRunnerColumnDefault PGTimestamptz UTCTime # 
QueryRunnerColumnDefault PGTimestamp LocalTime # 
QueryRunnerColumnDefault PGTime TimeOfDay # 
QueryRunnerColumnDefault PGText String # 
QueryRunnerColumnDefault PGText Text # 
QueryRunnerColumnDefault PGText Text # 
QueryRunnerColumnDefault PGInt4 Int # 
QueryRunnerColumnDefault PGInt4 Int32 # 
QueryRunnerColumnDefault PGInt8 Int64 # 
QueryRunnerColumnDefault PGFloat8 Double # 
QueryRunnerColumnDefault PGDate Day # 
QueryRunnerColumnDefault PGBool Bool # 
QueryRunnerColumnDefault PGCitext (CI Text) # 
QueryRunnerColumnDefault PGCitext (CI Text) # 
QueryRunnerColumnDefault a b => QueryRunnerColumnDefault (Nullable a) (Maybe b) # 
(Typeable * b, FromField b, QueryRunnerColumnDefault a b) => QueryRunnerColumnDefault (PGRange a) (PGRange b) # 
(Typeable * b, QueryRunnerColumnDefault a b) => QueryRunnerColumnDefault (PGArray a) [b] # 

prepareRowParser :: QueryRunner columns haskells -> columns -> RowParser haskells #