opaleye-0.7.3.0: An SQL-generating DSL targeting PostgreSQL
Safe HaskellNone
LanguageHaskell2010

Opaleye.Column

Description

Do not use. Will be deprecated in version 0.8. Use Opaleye.Field instead.

Functions for working directly with Columns.

Please note that numeric Column types are instances of Num, so you can use *, /, +, - on them.

Column will be renamed to Field_ in version 0.8, so you might want to use the latter as much as you can.

Synopsis

Column

data Column pgType Source #

A column of a Query, of type pgType. For example Column SqlInt4 is an int4 column and a Column SqlText is a text column.

The name Column will be replaced by Field in version 0.8. There already exists a Field type family to help smooth the transition. We recommend that you use Field_, Field or FieldNullable instead of Column everywhere that it is sufficient.

Instances

Instances details
Default ViewColumnMaker String (Column a) Source # 
Instance details

Defined in Opaleye.Internal.TableMaker

Default RelExprMaker String (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Operators

IsSqlType b => Default Nullspec a (Column b) Source # 
Instance details

Defined in Opaleye.Internal.Values

Methods

def :: Nullspec a (Column b) #

Default ToFields Bool (Column SqlBool) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Double (Column SqlFloat8) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int (Column SqlInt4) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int32 (Column SqlInt4) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int64 (Column SqlInt8) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlBytea) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlBytea) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Scientific (Column SqlNumeric) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields String (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Text (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields UTCTime (Column SqlTimestamptz) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Value (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Value (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Text (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ZonedTime (Column SqlTimestamptz) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields LocalTime (Column SqlTimestamp) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields TimeOfDay (Column SqlTime) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Day (Column SqlDate) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields UUID (Column SqlUuid) Source # 
Instance details

Defined in Opaleye.Internal.Constant

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

Defined in Opaleye.Internal.RunQuery

Methods

def :: FromFields (Column a) b #

Default Unpackspec (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Unpackspec

Methods

def :: Unpackspec (Column a) (Column a) #

Default Binaryspec (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Binary

Methods

def :: Binaryspec (Column a) (Column a) #

Default IfPP (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Operators

Methods

def :: IfPP (Column a) (Column a) #

Default EqPP (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Operators

Methods

def :: EqPP (Column a) (Column a) #

IsSqlType a => Default Valuesspec (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Values

Methods

def :: Valuesspec (Column a) (Column a) #

Default ValuesspecUnsafe (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Values

Methods

def :: ValuesspecUnsafe (Column a) (Column a) #

(Default ToFields a (Column b), IsSqlType b) => Default ToFields [a] (Column (SqlArray b)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields [a] (Column (SqlArray b)) #

Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Maybe (Column sql)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Maybe haskell) (Maybe (Column sql)) #

Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Column (Nullable sql)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Maybe haskell) (Column (Nullable sql)) #

Default ToFields (CI Text) (Column SqlCitext) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (CI Text) (Column SqlCitext) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Int) (Column (SqlRange SqlInt4)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Int64) (Column (SqlRange SqlInt8)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Scientific) (Column (SqlRange SqlNumeric)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange UTCTime) (Column (SqlRange SqlTimestamptz)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange LocalTime) (Column (SqlRange SqlTimestamp)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Day) (Column (SqlRange SqlDate)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Column a) (Column a) #

Default NullMaker (Column a) (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

Methods

def :: NullMaker (Column a) (Column (Nullable a)) #

Default NullMaker (Column (Nullable a)) (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

Methods

def :: NullMaker (Column (Nullable a)) (Column (Nullable a)) #

Default Distinctspec (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

def :: Distinctspec (Column a) (Column a) #

Default Updater (Column a) (Maybe (Column a)) Source # 
Instance details

Defined in Opaleye.Internal.Manipulation

Methods

def :: Updater (Column a) (Maybe (Column a)) #

Default Updater (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Manipulation

Methods

def :: Updater (Column a) (Column a) #

(SqlNum a, SqlFractional a) => Fractional (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Column

Methods

(/) :: Column a -> Column a -> Column a #

recip :: Column a -> Column a #

fromRational :: Rational -> Column a #

SqlNum a => Num (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Column

Methods

(+) :: Column a -> Column a -> Column a #

(-) :: Column a -> Column a -> Column a #

(*) :: Column a -> Column a -> Column a #

negate :: Column a -> Column a #

abs :: Column a -> Column a #

signum :: Column a -> Column a #

fromInteger :: Integer -> Column a #

SqlString a => IsString (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Column

Methods

fromString :: String -> Column a #

TableColumn (Maybe (Column a)) a Source # 
Instance details

Defined in Opaleye.Internal.Table

TableColumn (Column a) a Source # 
Instance details

Defined in Opaleye.Internal.Table

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

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromFields (Column a) b #

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

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromFields (Column (Nullable a)) maybe_b #

Column a ~ columnA => Default (Inferrable ToFields) (Column a) columnA Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (Column a) columnA #

(Profunctor p, IsSqlType a, Default p (Column a) (Column a)) => Default (WithNulls p) (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.MaybeFields

Methods

def :: WithNulls p (Column a) (Column a) #

type Map Nulled (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGJson) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGBytea) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGCitext) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGUuid) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGTimestamptz) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGTimestamp) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGTime) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGText) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGText) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGInt4) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGInt8) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGFloat8) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGDate) Source # 
Instance details

Defined in Opaleye.Internal.Join

type Map Nulled (Column PGBool) Source # 
Instance details

Defined in Opaleye.Internal.Join

Working with NULL

data Nullable a Source #

Only used within a Column, to indicate that it can be NULL. For example, a Column (Nullable SqlText) can be NULL but a Column SqlText cannot.

Instances

Instances details
Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Column (Nullable sql)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Maybe haskell) (Column (Nullable sql)) #

Default NullMaker (Column a) (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

Methods

def :: NullMaker (Column a) (Column (Nullable a)) #

Default NullMaker (Column (Nullable a)) (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

Methods

def :: NullMaker (Column (Nullable a)) (Column (Nullable a)) #

IsSqlType a => IsSqlType (Nullable a) Source # 
Instance details

Defined in Opaleye.Internal.PGTypes

Methods

showSqlType :: proxy (Nullable a) -> String Source #

SqlOrd a => SqlOrd (Nullable a) Source # 
Instance details

Defined in Opaleye.Order

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

Defined in Opaleye.Internal.RunQuery

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

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable FromFields (Column (Nullable a)) maybe_b #

type Map Nulled (Column (Nullable a)) Source # 
Instance details

Defined in Opaleye.Internal.Join

null :: Column (Nullable a) Source #

A NULL of any type

isNull :: Column (Nullable a) -> Column PGBool Source #

TRUE if the value of the column is NULL, FALSE otherwise.

matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b Source #

If the Column (Nullable a) is NULL then return the Column b otherwise map the underlying Column a using the provided function.

The Opaleye equivalent of maybe.

fromNullable :: Column a -> Column (Nullable a) -> Column a Source #

If the Column (Nullable a) is NULL then return the provided Column a otherwise return the underlying Column a.

The Opaleye equivalent of fromMaybe and very similar to PostgreSQL's COALESCE.

toNullable :: Column a -> Column (Nullable a) Source #

Treat a column as though it were nullable. This is always safe.

The Opaleye equivalent of Just.

maybeToNullable :: Maybe (Column a) -> Column (Nullable a) Source #

If the argument is Nothing return NULL otherwise return the provided value coerced to a nullable type.

Unsafe operations

unsafeCast :: String -> Column a -> Column b Source #

Cast a column to any other type. Implements Postgres's :: or CAST( ... AS ... ) operations. This is safe for some conversions, such as uuid to text.

unsafeCoerceColumn :: Column a -> Column b Source #

Treat a Column as though it were of a different type. If such a treatment is not valid then Postgres may fail with an error at SQL run time.

Entire module

null :: Column (Nullable a) Source #

A NULL of any type

isNull :: Column (Nullable a) -> Column PGBool Source #

TRUE if the value of the column is NULL, FALSE otherwise.

matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b Source #

If the Column (Nullable a) is NULL then return the Column b otherwise map the underlying Column a using the provided function.

The Opaleye equivalent of maybe.

fromNullable :: Column a -> Column (Nullable a) -> Column a Source #

If the Column (Nullable a) is NULL then return the provided Column a otherwise return the underlying Column a.

The Opaleye equivalent of fromMaybe and very similar to PostgreSQL's COALESCE.

toNullable :: Column a -> Column (Nullable a) Source #

Treat a column as though it were nullable. This is always safe.

The Opaleye equivalent of Just.

maybeToNullable :: Maybe (Column a) -> Column (Nullable a) Source #

If the argument is Nothing return NULL otherwise return the provided value coerced to a nullable type.