Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- where_ :: Field SqlBool -> Select ()
- restrict :: SelectArr (Field SqlBool) ()
- restrictExists :: SelectArr a b -> SelectArr a ()
- restrictNotExists :: SelectArr a b -> SelectArr a ()
- (+) :: Num a => a -> a -> a
- (-) :: Num a => a -> a -> a
- (*) :: Num a => a -> a -> a
- (/) :: Fractional a => a -> a -> a
- fromInteger :: Num a => Integer -> a
- abs :: Num a => a -> a
- negate :: Num a => a -> a
- signum :: Num a => a -> a
- (.==) :: Field a -> Field a -> Field SqlBool
- (./=) :: Field a -> Field a -> Field SqlBool
- (.===) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
- (./==) :: Default EqPP fields fields => fields -> fields -> Field SqlBool
- (.>) :: SqlOrd a => Field a -> Field a -> Field SqlBool
- (.<) :: SqlOrd a => Field a -> Field a -> Field SqlBool
- (.<=) :: SqlOrd a => Field a -> Field a -> Field SqlBool
- (.>=) :: SqlOrd a => Field a -> Field a -> Field SqlBool
- quot_ :: SqlIntegral a => Field a -> Field a -> Field a
- rem_ :: SqlIntegral a => Field a -> Field a -> Field a
- case_ :: [(Field SqlBool, Field_ n a)] -> Field_ n a -> Field_ n a
- ifThenElse :: Field SqlBool -> Field_ n a -> Field_ n a -> Field_ n 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
- sqlLength :: SqlString a => Field a -> Field SqlInt4
- in_ :: (Functor f, Foldable f) => f (Field a) -> Field a -> Field SqlBool
- inSelect :: Default EqPP fields fields => fields -> Select fields -> Select (Field SqlBool)
- class SqlIsJson json
- class SqlJsonIndex a
- type PGJsonIndex = SqlJsonIndex
- (.->) :: (SqlIsJson json, SqlJsonIndex k) => FieldNullable json -> Field k -> FieldNullable json
- (.->>) :: (SqlIsJson json, SqlJsonIndex k) => FieldNullable json -> Field k -> FieldNullable SqlText
- (.#>) :: SqlIsJson json => FieldNullable json -> Field (SqlArray SqlText) -> FieldNullable json
- (.#>>) :: SqlIsJson json => FieldNullable json -> Field (SqlArray SqlText) -> FieldNullable SqlText
- (.@>) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
- (.<@) :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
- (.?) :: Field SqlJsonb -> Field SqlText -> Field SqlBool
- (.?|) :: Field SqlJsonb -> Field (SqlArray SqlText) -> Field SqlBool
- (.?&) :: Field SqlJsonb -> Field (SqlArray SqlText) -> Field SqlBool
- jsonBuildObject :: JSONBuildObjectFields -> Field SqlJson
- jsonBuildObjectField :: String -> Field_ n a -> JSONBuildObjectFields
- data JSONBuildObjectFields
- emptyArray :: IsSqlType a => Field (SqlArray_ n a)
- arrayAppend :: Field (SqlArray_ n a) -> Field (SqlArray_ n a) -> Field (SqlArray_ n a)
- arrayPrepend :: Field_ n a -> Field (SqlArray_ n a) -> Field (SqlArray_ n a)
- arrayRemove :: Field_ n a -> Field (SqlArray_ n a) -> Field (SqlArray_ n a)
- arrayRemoveNulls :: Field (SqlArray_ Nullable a) -> Field (SqlArray a)
- singletonArray :: IsSqlType a => Field_ n a -> Field (SqlArray_ n a)
- index :: SqlIntegral n => Field (SqlArray_ n' a) -> Field n -> FieldNullable a
- arrayPosition :: Field (SqlArray_ n a) -> Field_ n a -> FieldNullable SqlInt4
- sqlElem :: Field_ n a -> Field (SqlArray_ n a) -> Field SqlBool
- overlap :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- liesWithin :: IsRangeType a => Field a -> Field (SqlRange a) -> Field SqlBool
- upperBound :: IsRangeType a => Field (SqlRange a) -> FieldNullable a
- lowerBound :: IsRangeType a => Field (SqlRange a) -> FieldNullable a
- (.<<) :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- (.>>) :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- (.&<) :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- (.&>) :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- (.-|-) :: Field (SqlRange a) -> Field (SqlRange a) -> Field SqlBool
- timestamptzAtTimeZone :: Field SqlTimestamptz -> Field SqlText -> Field SqlTimestamp
- dateOfTimestamp :: Field SqlTimestamp -> Field SqlDate
- now :: Field SqlTimestamptz
- class IntervalNum from to | from -> to
- addInterval :: IntervalNum from to => Field from -> Field SqlInterval -> Field to
- minusInterval :: IntervalNum from to => Field from -> Field SqlInterval -> Field to
- keepWhen :: (a -> Field SqlBool) -> SelectArr a a
Restriction operators
where_ :: Field SqlBool -> Select () Source #
Keep only the rows of a query satisfying a given condition, using an
SQL WHERE
clause. It is equivalent to the Haskell function
where_ :: Bool -> [()] where_ True = [()] where_ False = []
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.
Numerical operators
Numeric Column
/ Field
types are instances of Num
and Fractional
, so you can use the standard Haskell numerical
operators (e.g.. *
, /
, +
, -
) on them and you can create
them with numerical literals such as 3.14 ::
.Field
SqlFloat8
(/) :: Fractional a => a -> a -> a infixl 7 #
Fractional division.
fromInteger :: Num a => Integer -> a #
Conversion from an Integer
.
An integer literal represents the application of the function
fromInteger
to the appropriate value of type Integer
,
so such literals have type (
.Num
a) => a
Equality operators
(.===) :: 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.
Comparison operators
Numerical operators
quot_ :: SqlIntegral a => Field a -> Field a -> Field a Source #
Integral division, named after quot
. It maps to the
/
operator in Postgres.
rem_ :: SqlIntegral a => Field a -> Field a -> Field a Source #
The remainder of integral division, named after rem
.
It maps to MOD
(%
) in Postgres, confusingly described as
"modulo (remainder)".
Conditional operators
case_ :: [(Field SqlBool, Field_ n a)] -> Field_ n a -> Field_ n a Source #
Select the first case for which the condition is true.
ifThenElse :: Field SqlBool -> Field_ n a -> Field_ n a -> Field_ n 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.
Logical operators
ors :: Foldable f => f (Field SqlBool) -> Field SqlBool Source #
True when any element of the container is true
Text operators
Containment operators
inSelect :: Default EqPP fields fields => fields -> Select 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.
JSON 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
SqlIsJson SqlJsonb Source # | |
Defined in Opaleye.Operators | |
SqlIsJson SqlJson Source # | |
Defined in Opaleye.Operators |
class SqlJsonIndex 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
SqlJsonIndex SqlText Source # | |
Defined in Opaleye.Operators | |
SqlJsonIndex SqlInt4 Source # | |
Defined in Opaleye.Operators | |
SqlJsonIndex SqlInt8 Source # | |
Defined in Opaleye.Operators |
type PGJsonIndex = SqlJsonIndex Source #
Use SqlJsonIndex
instead. Will be deprecated in a future version.
:: (SqlIsJson json, SqlJsonIndex k) | |
=> FieldNullable json | |
-> Field k | key or index |
-> FieldNullable json |
Get JSON object field by key.
:: (SqlIsJson json, SqlJsonIndex k) | |
=> FieldNullable json | |
-> Field k | key or index |
-> FieldNullable SqlText |
Get JSON object field as text.
:: SqlIsJson json | |
=> FieldNullable json | |
-> Field (SqlArray SqlText) | path |
-> FieldNullable json |
Get JSON object at specified path.
:: SqlIsJson json | |
=> FieldNullable json | |
-> Field (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 -> Field (SqlArray SqlText) -> Field SqlBool infix 4 Source #
Do any of these key/element strings exist?
(.?&) :: Field SqlJsonb -> Field (SqlArray SqlText) -> Field SqlBool infix 4 Source #
Do all of these key/element strings exist?
jsonBuildObject :: JSONBuildObjectFields -> Field SqlJson Source #
Create an SqlJson
object from a collection of fields.
Note: This is implemented as a variadic function in postgres, and as such, is limited to 50 arguments, or 25 key-value pairs.
:: String | Field name |
-> Field_ n a | Field value |
-> JSONBuildObjectFields |
Given a label and a field, generates a pair for use with jsonBuildObject
data JSONBuildObjectFields Source #
Combine JSONBuildObjectFields
using (
<>
)
SqlArray operators
arrayAppend :: Field (SqlArray_ n a) -> Field (SqlArray_ n a) -> Field (SqlArray_ n a) Source #
Append two SqlArray
s
arrayPrepend :: Field_ n a -> Field (SqlArray_ n a) -> Field (SqlArray_ n a) Source #
Prepend an element to a SqlArray
arrayRemove :: Field_ n a -> Field (SqlArray_ n a) -> Field (SqlArray_ n a) Source #
Remove all instances of an element from a SqlArray
arrayRemoveNulls :: Field (SqlArray_ Nullable a) -> Field (SqlArray a) Source #
Remove all NULL
values from a SqlArray
index :: SqlIntegral n => Field (SqlArray_ n' a) -> Field n -> FieldNullable a Source #
:: Field (SqlArray_ n a) | Haystack |
-> Field_ n a | Needle |
-> FieldNullable SqlInt4 |
Postgres's array_position
Whether the element (needle) exists in the array (haystack).
N.B. this is implemented hackily using array_position
. If you
need it to be implemented using = any
then please open an issue.
Range operators
liesWithin :: IsRangeType a => Field a -> Field (SqlRange a) -> Field SqlBool Source #
upperBound :: IsRangeType a => Field (SqlRange a) -> FieldNullable a Source #
Access the upper bound of a range. For discrete range types it is the exclusive bound.
lowerBound :: IsRangeType a => Field (SqlRange a) -> FieldNullable a Source #
Access the lower bound of a range. For discrete range types it is the inclusive bound.
Other operators
now :: Field SqlTimestamptz Source #
Current date and time (start of current transaction)
class IntervalNum from to | from -> to Source #
IntervalNum from to
determines from which date or time types an interval
can be added (addInterval
) or subtracted (minusInterval
) and which is the
resulting type.
The instances should correspond to the interval + and - operations listed in:
https://www.postgresql.org/docs/current/functions-datetime.html#OPERATORS-DATETIME-TABLE
Instances
IntervalNum SqlTimestamptz SqlTimestamptz Source # | |
Defined in Opaleye.Operators | |
IntervalNum SqlTimestamp SqlTimestamp Source # | |
Defined in Opaleye.Operators | |
IntervalNum SqlTime SqlTime Source # | |
Defined in Opaleye.Operators | |
IntervalNum SqlInterval SqlInterval Source # | |
Defined in Opaleye.Operators | |
IntervalNum SqlDate SqlTimestamp Source # | |
Defined in Opaleye.Operators |
addInterval :: IntervalNum from to => Field from -> Field SqlInterval -> Field to Source #
minusInterval :: IntervalNum from to => Field from -> Field SqlInterval -> Field to Source #