opaleye-0.5.2.2: An SQL-generating DSL targeting PostgreSQL

Safe HaskellNone
LanguageHaskell2010

Opaleye.Column

Contents

Description

Functions for working directly with Columns.

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

Synopsis

Column

data Column pgType Source #

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

Instances

Default Constant Bool (Column PGBool) # 
Default Constant Double (Column PGFloat8) # 
Default Constant Int (Column PGInt4) # 
Default Constant Int32 (Column PGInt4) # 
Default Constant Int64 (Column PGInt8) # 
Default Constant ByteString (Column PGJsonb) # 
Default Constant ByteString (Column PGJson) # 
Default Constant ByteString (Column PGBytea) # 
Default Constant ByteString (Column PGJsonb) # 
Default Constant ByteString (Column PGJson) # 
Default Constant ByteString (Column PGBytea) # 
Default Constant String (Column PGText) # 
Default Constant Text (Column PGText) # 
Default Constant UTCTime (Column PGTimestamptz) # 
Default Constant Value (Column PGJsonb) # 
Default Constant Value (Column PGJson) # 
Default Constant Text (Column PGText) # 
Default Constant LocalTime (Column PGTimestamp) # 
Default Constant TimeOfDay (Column PGTime) # 
Default Constant Day (Column PGDate) # 
Default Constant UUID (Column PGUuid) # 
Default ViewColumnMaker String (Column a) # 
Default RelExprMaker String (Column a) # 
QueryRunnerColumnDefault a b => Default QueryRunner (Column a) b # 

Methods

def :: QueryRunner (Column a) b #

(Default Constant a (Column b), IsSqlType b) => Default Constant [a] (Column (PGArray b)) # 

Methods

def :: Constant [a] (Column (PGArray b)) #

Default Constant haskell (Column sql) => Default Constant (Maybe haskell) (Maybe (Column sql)) # 

Methods

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

Default Constant haskell (Column sql) => Default Constant (Maybe haskell) (Column (Nullable sql)) # 

Methods

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

Default Constant (CI Text) (Column PGCitext) # 
Default Constant (CI Text) (Column PGCitext) # 
Default ColumnMaker (Column a) (Column a) # 

Methods

def :: ColumnMaker (Column a) (Column a) #

Default Unpackspec (Column a) (Column a) # 

Methods

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

Default Binaryspec (Column a) (Column a) # 

Methods

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

Default NullMaker (Column a) (Column (Nullable a)) # 

Methods

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

Default NullMaker (Column (Nullable a)) (Column (Nullable a)) # 

Methods

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

Default IfPP (Column a) (Column a) # 

Methods

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

Default EqPP (Column a) (Column a) # 

Methods

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

Default Valuesspec (Column a) (Column a) # 

Methods

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

Default Distinctspec (Column a) (Column a) # 

Methods

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

(PGNum a, PGFractional a) => Fractional (Column a) Source # 

Methods

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

recip :: Column a -> Column a #

fromRational :: Rational -> Column a #

PGNum a => Num (Column a) Source # 

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 #

Show (Column pgType) Source # 

Methods

showsPrec :: Int -> Column pgType -> ShowS #

show :: Column pgType -> String #

showList :: [Column pgType] -> ShowS #

PGString a => IsString (Column a) Source # 

Methods

fromString :: String -> Column a #

Working with NULL

data Nullable a Source #

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

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.

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.

unsafeCoerce :: Column a -> Column b Source #

Deprecated: Will be removed in version 0.6. Use unsafeCoerceColumn instead.

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.

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.