| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Opaleye.Operators
Description
Synopsis
- type SqlJsonIndex = PGJsonIndex
- class PGJsonIndex a
- type SqlIsJson = PGIsJson
- class PGIsJson a
- restrict :: SelectArr (Field SqlBool) ()
- restrictExists :: SelectArr a b -> SelectArr a ()
- restrictNotExists :: SelectArr a b -> SelectArr a ()
- keepWhen :: (a -> Field SqlBool) -> SelectArr a a
- (.==) :: Column a -> Column a -> Field SqlBool
- (./=) :: Column a -> Column a -> Field SqlBool
- (.===) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
- (./==) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
- (.>) :: SqlOrd a => Column a -> Column a -> Field SqlBool
- (.<) :: SqlOrd a => Column a -> Column a -> Field SqlBool
- (.<=) :: SqlOrd a => Column a -> Column a -> Field SqlBool
- (.>=) :: SqlOrd a => Column a -> Column a -> Field SqlBool
- quot_ :: SqlIntegral a => Column a -> Column a -> Column a
- rem_ :: SqlIntegral a => Column a -> Column a -> Column a
- case_ :: [(Field SqlBool, Column a)] -> Column a -> Column a
- ifThenElse :: Field SqlBool -> Column a -> Column a -> Column a
- ifThenElseMany :: Default IfPP fields fields => Field SqlBool -> fields -> fields -> fields
- (.||) :: Field SqlBool -> Field SqlBool -> Field SqlBool
- (.&&) :: Field SqlBool -> Field SqlBool -> Field SqlBool
- not :: Field SqlBool -> Field SqlBool
- ors :: Foldable f => f (Field SqlBool) -> Field SqlBool
- (.++) :: Field SqlText -> Field SqlText -> Field SqlText
- lower :: Field SqlText -> Field SqlText
- upper :: Field SqlText -> Field SqlText
- like :: Field SqlText -> Field SqlText -> Field SqlBool
- ilike :: Field SqlText -> Field SqlText -> Field SqlBool
- charLength :: PGString a => Column a -> Column Int
- in_ :: (Functor f, Foldable f) => f (Column a) -> Column a -> Field SqlBool
- inQuery :: Default EqPP fields fields => fields -> Query fields -> Select (Field SqlBool)
- (.->) :: (SqlIsJson a, SqlJsonIndex k) => FieldNullable a -> Field k -> FieldNullable a
- (.->>) :: (SqlIsJson a, SqlJsonIndex k) => FieldNullable a -> Field k -> FieldNullable SqlText
- (.#>) :: SqlIsJson a => FieldNullable a -> Column (SqlArray SqlText) -> FieldNullable a
- (.#>>) :: SqlIsJson a => FieldNullable a -> Column (SqlArray SqlText) -> FieldNullable SqlText
- (.@>) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
- (.<@) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
- (.?) :: Field SqlJsonb -> Field SqlText -> Field SqlBool
- (.?|) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
- (.?&) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
- emptyArray :: IsSqlType a => Column (SqlArray a)
- arrayPrepend :: Column a -> Column (SqlArray a) -> Column (SqlArray a)
- singletonArray :: IsSqlType a => Column a -> Column (SqlArray a)
- index :: SqlIntegral n => Column (SqlArray a) -> Column n -> Column (Nullable a)
- overlap :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- liesWithin :: IsRangeType a => Column a -> Column (SqlRange a) -> Field SqlBool
- upperBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a)
- lowerBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a)
- (.<<) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- (.>>) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- (.&<) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- (.&>) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- (.-|-) :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
- timestamptzAtTimeZone :: Field SqlTimestamptz -> Field SqlText -> Field SqlTimestamp
- doubleOfInt :: Field SqlInt4 -> Field SqlFloat8
- exists :: QueryArr a b -> QueryArr a ()
- notExists :: QueryArr a b -> QueryArr a ()
Documentation
type SqlJsonIndex = PGJsonIndex Source #
class PGJsonIndex a Source #
Class of Postgres types that can be used to index json values.
Warning: making additional instances of this class can lead to broken code!
Instances
| PGJsonIndex SqlText Source # | |
Defined in Opaleye.Operators | |
| PGJsonIndex SqlInt4 Source # | |
Defined in Opaleye.Operators | |
| PGJsonIndex SqlInt8 Source # | |
Defined in Opaleye.Operators | |
Class of Postgres types that represent json values.
Used to overload functions and operators that work on both SqlJson and SqlJsonb.
Warning: making additional instances of this class can lead to broken code!
Instances
| PGIsJson SqlJsonb Source # | |
Defined in Opaleye.Operators | |
| PGIsJson SqlJson Source # | |
Defined in Opaleye.Operators | |
restrict :: SelectArr (Field SqlBool) () Source #
Keep only the rows of a query satisfying a given condition, using
an SQL WHERE clause.
You would typically use restrict if you want to write your query
using Arrow notation. If you want to use a "point free" style
then keepWhen will suit you better.
(If you are familiar with MonadPlus or
Alternative it may help you to know that
restrict corresponds to the guard function.)
restrictExists :: SelectArr a b -> SelectArr a () Source #
Add a WHERE EXISTS clause to the current query.
restrictNotExists :: SelectArr a b -> SelectArr a () Source #
Add a WHERE NOT EXISTS clause to the current query.
keepWhen :: (a -> Field SqlBool) -> SelectArr a a Source #
Keep only the rows of a query satisfying a given condition, using
an SQL WHERE clause.
You would typically use keepWhen if you want to write
your query using a "point free" style. If you want to use Arrow
notation then restrict will suit you better.
This is the SelectArr equivalent of filter from the
Prelude.
(.===) :: Default EqPP fields fields => fields -> fields -> Field SqlBool infix 4 Source #
A polymorphic equality operator that works for all types that you
have run makeAdaptorAndInstance on. This may be unified with
.== in a future version.
(./==) :: Default EqPP fields fields => fields -> fields -> Field SqlBool infix 4 Source #
A polymorphic inequality operator that works for all types that
you have run makeAdaptorAndInstance on. This may be unified with
./= in a future version.
quot_ :: SqlIntegral a => Column a -> Column a -> Column a Source #
Integral division, named after quot. It maps to the
/ operator in Postgres.
rem_ :: SqlIntegral a => Column a -> Column a -> Column a Source #
The remainder of integral division, named after rem.
It maps to MOD (%) in Postgres, confusingly described as
"modulo (remainder)".
case_ :: [(Field SqlBool, Column a)] -> Column a -> Column a Source #
Select the first case for which the condition is true.
ifThenElse :: Field SqlBool -> Column a -> Column a -> Column a Source #
Monomorphic if/then/else.
This may be replaced by ifThenElseMany in a future version.
ifThenElseMany :: Default IfPP fields fields => Field SqlBool -> fields -> fields -> fields Source #
Polymorphic if/then/else.
ors :: Foldable f => f (Field SqlBool) -> Field SqlBool Source #
True when any element of the container is true
inQuery :: Default EqPP fields fields => fields -> Query fields -> Select (Field SqlBool) Source #
True if the first argument occurs amongst the rows of the second, false otherwise.
This operation is equivalent to Postgres's IN operator but, for
expediency, is currently implemented using a LEFT JOIN. Please
file a bug if this causes any issues in practice.
Arguments
| :: (SqlIsJson a, SqlJsonIndex k) | |
| => FieldNullable a | |
| -> Field k | key or index |
| -> FieldNullable a |
Get JSON object field by key.
Arguments
| :: (SqlIsJson a, SqlJsonIndex k) | |
| => FieldNullable a | |
| -> Field k | key or index |
| -> FieldNullable SqlText |
Get JSON object field as text.
Arguments
| :: SqlIsJson a | |
| => FieldNullable a | |
| -> Column (SqlArray SqlText) | path |
| -> FieldNullable a |
Get JSON object at specified path.
Arguments
| :: SqlIsJson a | |
| => FieldNullable a | |
| -> Column (SqlArray SqlText) | path |
| -> FieldNullable SqlText |
Get JSON object at specified path as text.
(.@>) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool infix 4 Source #
Does the left JSON value contain within it the right value?
(.<@) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool infix 4 Source #
Is the left JSON value contained within the right value?
(.?) :: Field SqlJsonb -> Field SqlText -> Field SqlBool infix 4 Source #
Does the key/element string exist within the JSON value?
(.?|) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool infix 4 Source #
Do any of these key/element strings exist?
(.?&) :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool infix 4 Source #
Do all of these key/element strings exist?
liesWithin :: IsRangeType a => Column a -> Column (SqlRange a) -> Field SqlBool Source #
upperBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a) Source #
Access the upper bound of a range. For discrete range types it is the exclusive bound.
lowerBound :: IsRangeType a => Column (SqlRange a) -> Column (Nullable a) Source #
Access the lower bound of a range. For discrete range types it is the inclusive bound.
doubleOfInt :: Field SqlInt4 -> Field SqlFloat8 Source #
Deprecated: Use unsafeCast instead. Will be removed in version 0.7.