opaleye-0.9.6.1: An SQL-generating DSL targeting PostgreSQL
Safe HaskellSafe-Inferred
LanguageHaskell2010

Opaleye.Internal.RunQuery

Synopsis

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

Instances details
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 #

bool ~ Bool => Default (Inferrable FromField) SqlBool bool Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

bytestring ~ ByteString => Default (Inferrable FromField) SqlBytea bytestring Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlBytea bytestring #

cttext ~ CI Text => Default (Inferrable FromField) SqlCitext cttext Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

day ~ Day => Default (Inferrable FromField) SqlDate day Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

double ~ Double => Default (Inferrable FromField) SqlFloat8 double Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

int ~ Int => Default (Inferrable FromField) SqlInt4 int Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

int64 ~ Int64 => Default (Inferrable FromField) SqlInt8 int64 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlInt8 int64 #

calendardifftime ~ CalendarDiffTime => Default (Inferrable FromField) SqlInterval calendardifftime Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlInterval calendardifftime #

scientific ~ Scientific => Default (Inferrable FromField) SqlNumeric scientific Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlNumeric scientific #

text ~ Text => Default (Inferrable FromField) SqlText text Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

timeofday ~ TimeOfDay => Default (Inferrable FromField) SqlTime timeofday Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlTime timeofday #

localtime ~ LocalTime => Default (Inferrable FromField) SqlTimestamp localtime Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField SqlTimestamp localtime #

uuid ~ UUID => Default (Inferrable FromField) SqlUuid uuid Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

varchar ~ Text => Default (Inferrable FromField) SqlVarcharN varchar Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

(Typeable h, Default (Inferrable FromField) f h, hs ~ [h]) => Default (Inferrable FromField) (SqlArray f) hs Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromField (SqlArray f) hs #

(Typeable h, Default (Inferrable FromField) f h, hs ~ [Maybe h]) => Default (Inferrable FromField) (SqlArray_ 'Nullable f) hs Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

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

Instances details
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') #

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 #

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

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

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

Defined in Opaleye.Internal.RunQuery

Methods

def :: FromFields (Field a) b #

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

Defined in Opaleye.Internal.RunQuery

Methods

def :: FromFields (FieldNullable a) (Maybe b) #

Default FromFields fields haskells => Default FromFields (MaybeFields fields) (Maybe haskells) Source # 
Instance details

Defined in Opaleye.Internal.MaybeFields

Methods

def :: FromFields (MaybeFields fields) (Maybe haskells) #

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 #

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 #

Default (Inferrable FromField) a b => Default (Inferrable FromFields) (Field a) b Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromFields (Field a) b #

(Default (Inferrable FromField) a b, Maybe b ~ maybe_b) => Default (Inferrable FromFields) (FieldNullable a) maybe_b Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromFields (FieldNullable a) maybe_b #

(Default (Inferrable FromFields) fields haskells, Maybe haskells ~ maybe_haskells) => Default (Inferrable FromFields) (MaybeFields fields) maybe_haskells Source # 
Instance details

Defined in Opaleye.Internal.MaybeFields

Methods

def :: Inferrable FromFields (MaybeFields fields) maybe_haskells #

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

Deprecated: Will be removed in version 0.10. Use fromPGSFromField instead.

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

fieldParserQueryRunnerColumn :: FieldParser haskell -> FromField pgType haskell Source #

Deprecated: Will be removed in version 0.10. Use fromPGSFieldParser instead.

fromPGSFieldParser :: FieldParser haskell -> FromField pgType haskell Source #

queryRunner :: FromField a b -> FromFields (Field a) b Source #

Deprecated: Use fromFields instead. Will be removed in version 0.10.

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.

  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.

Methods

defaultFromField :: FromField sqlType haskellType Source #

Instances

Instances details
DefaultFromField SqlBool Bool Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlBytea ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlBytea ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlDate Day Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlFloat8 Double Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlInt4 Int32 Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlInt4 Int Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlInt8 Int64 Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlInterval CalendarDiffTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson Value Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJson String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb Value Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb ByteString Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlJsonb String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlNumeric Scientific Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlText Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlText Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlText String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlTime TimeOfDay Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlTimestamp LocalTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlTimestamptz UTCTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlTimestamptz ZonedTime Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlUuid UUID Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlVarcharN Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlVarcharN Text Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlVarcharN String Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlCitext (CI Text) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

DefaultFromField SqlCitext (CI Text) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

(FromJSON a, Typeable a) => DefaultFromField SqlJson (Aeson a) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

(FromJSON a, Typeable a) => DefaultFromField SqlJsonb (Aeson a) Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

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

Defined in Opaleye.Internal.RunQuery

(Typeable b, DefaultFromField a b) => DefaultFromField (SqlArray_ 'NonNullable a) [b] Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

(Typeable b, DefaultFromField a b) => DefaultFromField (SqlArray_ 'Nullable a) [Maybe b] Source # 
Instance details

Defined in Opaleye.Internal.RunQuery

prepareRowParser :: FromFields columns haskells -> columns -> RowParser haskells Source #

data Cursor haskells Source #

Cursor within a transaction.

Constructors

EmptyCursor 
Cursor (RowParser haskells) Cursor 

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