Safe Haskell | None |
---|---|
Language | Haskell2010 |
Do not use. Will be deprecated in version 0.8. Use Opaleye.Field instead.
Functions for working directly with Column
s.
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
- data Column pgType
- data Nullable a
- null :: Column (Nullable a)
- isNull :: Column (Nullable a) -> Column PGBool
- matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b
- fromNullable :: Column a -> Column (Nullable a) -> Column a
- toNullable :: Column a -> Column (Nullable a)
- maybeToNullable :: Maybe (Column a) -> Column (Nullable a)
- unsafeCast :: String -> Column a -> Column b
- unsafeCoerceColumn :: Column a -> Column b
- unsafeCompositeField :: Column a -> String -> Column b
- null :: Column (Nullable a)
- isNull :: Column (Nullable a) -> Column PGBool
- matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b
- fromNullable :: Column a -> Column (Nullable a) -> Column a
- toNullable :: Column a -> Column (Nullable a)
- maybeToNullable :: Maybe (Column a) -> Column (Nullable a)
- joinNullable :: Column (Nullable (Nullable a)) -> Column (Nullable a)
Column
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
Working with NULL
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
Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Column (Nullable sql)) Source # | |
Default NullMaker (Column a) (Column (Nullable a)) Source # | |
Default NullMaker (Column (Nullable a)) (Column (Nullable a)) Source # | |
IsSqlType a => IsSqlType (Nullable a) Source # | |
Defined in Opaleye.Internal.PGTypes showSqlType :: proxy (Nullable a) -> String Source # | |
SqlOrd a => SqlOrd (Nullable a) Source # | |
Defined in Opaleye.Order | |
DefaultFromField a b => DefaultFromField (Nullable a) (Maybe b) Source # | |
Defined in Opaleye.Internal.RunQuery | |
(Default (Inferrable FromField) a b, Maybe b ~ maybe_b) => Default (Inferrable FromFields) (Column (Nullable a)) maybe_b Source # | |
Defined in Opaleye.Internal.Inferrable def :: Inferrable FromFields (Column (Nullable a)) maybe_b # | |
type Map Nulled (Column (Nullable a)) Source # | |
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
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
.