{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Opaleye.Operators
(
where_
, restrict
, restrictExists
, restrictNotExists
, (+)
, (-)
, (*)
, (/)
, fromInteger
, abs
, negate
, signum
, (.==)
, (./=)
, (.===)
, (./==)
, (.>)
, (.<)
, (.<=)
, (.>=)
, quot_
, rem_
, case_
, ifThenElse
, ifThenElseMany
, (.||)
, (.&&)
, not
, ors
, (.++)
, lower
, upper
, like
, ilike
, charLength
, sqlLength
, in_
, inSelect
, SqlIsJson
, PGIsJson
, SqlJsonIndex
, PGJsonIndex
, (.->)
, (.->>)
, (.#>)
, (.#>>)
, (.@>)
, (.<@)
, (.?)
, (.?|)
, (.?&)
, JBOF.jsonBuildObject
, JBOF.jsonBuildObjectField
, JBOF.JSONBuildObjectFields
, emptyArray
, arrayAppend
, arrayPrepend
, arrayRemove
, arrayRemoveNulls
, singletonArray
, index
, arrayPosition
, sqlElem
, overlap
, liesWithin
, upperBound
, lowerBound
, (.<<)
, (.>>)
, (.&<)
, (.&>)
, (.-|-)
, timestamptzAtTimeZone
, dateOfTimestamp
, now
, exists
, notExists
, inQuery
, keepWhen
)
where
import qualified Control.Arrow as A
import qualified Data.Foldable as F
import qualified Data.List.NonEmpty as NEL
import Prelude hiding (not)
import qualified Opaleye.Exists as E
import qualified Opaleye.Field as F
import Opaleye.Internal.Column (Column(Column), unsafeCase_,
unsafeIfThenElse, unsafeGt)
import qualified Opaleye.Internal.Column as C
import qualified Opaleye.Internal.JSONBuildObjectFields as JBOF
import Opaleye.Internal.QueryArr (SelectArr(QueryArr),
Query, QueryArr, runSimpleQueryArr)
import qualified Opaleye.Internal.PrimQuery as PQ
import qualified Opaleye.Internal.Operators as O
import Opaleye.Internal.Helpers ((.:))
import qualified Opaleye.Lateral as L
import qualified Opaleye.Order as Ord
import qualified Opaleye.Select as S
import qualified Opaleye.SqlTypes as T
import qualified Opaleye.Column as Column
import qualified Opaleye.Internal.HaskellDB.PrimQuery as HPQ
import qualified Data.Profunctor.Product.Default as D
where_ :: F.Field T.SqlBool -> S.Select ()
where_ :: Field SqlBool -> Select ()
where_ = SelectArr (Column SqlBool) () -> Column SqlBool -> Select ()
forall i a. SelectArr i a -> i -> Select a
L.viaLateral SelectArr (Column SqlBool) ()
SelectArr (Field SqlBool) ()
restrict
restrict :: S.SelectArr (F.Field T.SqlBool) ()
restrict :: SelectArr (Field SqlBool) ()
restrict = SelectArr (Field SqlBool) ()
O.restrict
restrictExists :: S.SelectArr a b -> S.SelectArr a ()
restrictExists :: SelectArr a b -> SelectArr a ()
restrictExists SelectArr a b
criteria = ((a, Tag) -> ((), Lateral -> PrimQuery -> PrimQuery, Tag))
-> SelectArr a ()
forall a b.
((a, Tag) -> (b, Lateral -> PrimQuery -> PrimQuery, Tag))
-> SelectArr a b
QueryArr (a, Tag) -> ((), Lateral -> PrimQuery -> PrimQuery, Tag)
forall p. (a, Tag) -> ((), p -> PrimQuery -> PrimQuery, Tag)
f where
f :: (a, Tag) -> ((), p -> PrimQuery -> PrimQuery, Tag)
f (a
a, Tag
t0) = ((), \p
_ PrimQuery
primQ -> SemijoinType -> PrimQuery -> PrimQuery -> PrimQuery
forall a.
SemijoinType -> PrimQuery' a -> PrimQuery' a -> PrimQuery' a
PQ.Semijoin SemijoinType
PQ.Semi PrimQuery
primQ PrimQuery
existsQ, Tag
t1) where
(b
_, PrimQuery
existsQ, Tag
t1) = SelectArr a b -> (a, Tag) -> (b, PrimQuery, Tag)
forall a b. QueryArr a b -> (a, Tag) -> (b, PrimQuery, Tag)
runSimpleQueryArr SelectArr a b
criteria (a
a, Tag
t0)
restrictNotExists :: S.SelectArr a b -> S.SelectArr a ()
restrictNotExists :: SelectArr a b -> SelectArr a ()
restrictNotExists SelectArr a b
criteria = ((a, Tag) -> ((), Lateral -> PrimQuery -> PrimQuery, Tag))
-> SelectArr a ()
forall a b.
((a, Tag) -> (b, Lateral -> PrimQuery -> PrimQuery, Tag))
-> SelectArr a b
QueryArr (a, Tag) -> ((), Lateral -> PrimQuery -> PrimQuery, Tag)
forall p. (a, Tag) -> ((), p -> PrimQuery -> PrimQuery, Tag)
f where
f :: (a, Tag) -> ((), p -> PrimQuery -> PrimQuery, Tag)
f (a
a, Tag
t0) = ((), \p
_ PrimQuery
primQ -> SemijoinType -> PrimQuery -> PrimQuery -> PrimQuery
forall a.
SemijoinType -> PrimQuery' a -> PrimQuery' a -> PrimQuery' a
PQ.Semijoin SemijoinType
PQ.Anti PrimQuery
primQ PrimQuery
existsQ, Tag
t1) where
(b
_, PrimQuery
existsQ, Tag
t1) = SelectArr a b -> (a, Tag) -> (b, PrimQuery, Tag)
forall a b. QueryArr a b -> (a, Tag) -> (b, PrimQuery, Tag)
runSimpleQueryArr SelectArr a b
criteria (a
a, Tag
t0)
infix 4 .==
(.==) :: Column a -> Column a -> F.Field T.SqlBool
.== :: Column a -> Column a -> Field SqlBool
(.==) = BinOp -> Column a -> Column a -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:==)
infix 4 ./=
(./=) :: Column a -> Column a -> F.Field T.SqlBool
./= :: Column a -> Column a -> Field SqlBool
(./=) = BinOp -> Column a -> Column a -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<>)
infix 4 .===
(.===) :: D.Default O.EqPP fields fields => fields -> fields -> F.Field T.SqlBool
.=== :: fields -> fields -> Field SqlBool
(.===) = fields -> fields -> Field SqlBool
forall columns.
Default EqPP columns columns =>
columns -> columns -> Column SqlBool
(O..==)
infix 4 ./==
(./==) :: D.Default O.EqPP fields fields => fields -> fields -> F.Field T.SqlBool
./== :: fields -> fields -> Field SqlBool
(./==) = Column SqlBool -> Column SqlBool
Field SqlBool -> Field SqlBool
Opaleye.Operators.not (Column SqlBool -> Column SqlBool)
-> (fields -> fields -> Column SqlBool)
-> fields
-> fields
-> Column SqlBool
forall r z a b. (r -> z) -> (a -> b -> r) -> a -> b -> z
.: fields -> fields -> Column SqlBool
forall columns.
Default EqPP columns columns =>
columns -> columns -> Column SqlBool
(O..==)
infix 4 .>
(.>) :: Ord.SqlOrd a => Column a -> Column a -> F.Field T.SqlBool
.> :: Column a -> Column a -> Field SqlBool
(.>) = Column a -> Column a -> Field SqlBool
forall a pgBool. Column a -> Column a -> Column pgBool
unsafeGt
infix 4 .<
(.<) :: Ord.SqlOrd a => Column a -> Column a -> F.Field T.SqlBool
.< :: Column a -> Column a -> Field SqlBool
(.<) = BinOp -> Column a -> Column a -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<)
infix 4 .<=
(.<=) :: Ord.SqlOrd a => Column a -> Column a -> F.Field T.SqlBool
.<= :: Column a -> Column a -> Field SqlBool
(.<=) = BinOp -> Column a -> Column a -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<=)
infix 4 .>=
(.>=) :: Ord.SqlOrd a => Column a -> Column a -> F.Field T.SqlBool
.>= :: Column a -> Column a -> Field SqlBool
(.>=) = BinOp -> Column a -> Column a -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:>=)
quot_ :: C.SqlIntegral a => Column a -> Column a -> Column a
quot_ :: Column a -> Column a -> Column a
quot_ = BinOp -> Column a -> Column a -> Column a
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:/)
rem_ :: C.SqlIntegral a => Column a -> Column a -> Column a
rem_ :: Column a -> Column a -> Column a
rem_ = BinOp -> Column a -> Column a -> Column a
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
HPQ.OpMod
case_ :: [(F.Field T.SqlBool, Column a)] -> Column a -> Column a
case_ :: [(Field SqlBool, Column a)] -> Column a -> Column a
case_ = [(Field SqlBool, Column a)] -> Column a -> Column a
forall pgBool a.
[(Column pgBool, Column a)] -> Column a -> Column a
unsafeCase_
ifThenElse :: F.Field T.SqlBool -> Column a -> Column a -> Column a
ifThenElse :: Field SqlBool -> Column a -> Column a -> Column a
ifThenElse = Field SqlBool -> Column a -> Column a -> Column a
forall pgBool a. Column pgBool -> Column a -> Column a -> Column a
unsafeIfThenElse
ifThenElseMany :: D.Default O.IfPP fields fields
=> F.Field T.SqlBool
-> fields
-> fields
-> fields
ifThenElseMany :: Field SqlBool -> fields -> fields -> fields
ifThenElseMany = IfPP fields fields -> Column SqlBool -> fields -> fields -> fields
forall columns columns'.
IfPP columns columns'
-> Column SqlBool -> columns -> columns -> columns'
O.ifExplict IfPP fields fields
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def
infixr 2 .||
(.||) :: F.Field T.SqlBool -> F.Field T.SqlBool -> F.Field T.SqlBool
.|| :: Field SqlBool -> Field SqlBool -> Field SqlBool
(.||) = Field SqlBool -> Field SqlBool -> Field SqlBool
(O..||)
infixr 3 .&&
(.&&) :: F.Field T.SqlBool -> F.Field T.SqlBool -> F.Field T.SqlBool
.&& :: Field SqlBool -> Field SqlBool -> Field SqlBool
(.&&) = Column SqlBool -> Column SqlBool -> Column SqlBool
Field SqlBool -> Field SqlBool -> Field SqlBool
(O..&&)
not :: F.Field T.SqlBool -> F.Field T.SqlBool
not :: Field SqlBool -> Field SqlBool
not = Field SqlBool -> Field SqlBool
O.not
ors :: F.Foldable f => f (F.Field T.SqlBool) -> F.Field T.SqlBool
ors :: f (Field SqlBool) -> Field SqlBool
ors = (Column SqlBool -> Column SqlBool -> Column SqlBool)
-> Column SqlBool -> f (Column SqlBool) -> Column SqlBool
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl' Column SqlBool -> Column SqlBool -> Column SqlBool
Field SqlBool -> Field SqlBool -> Field SqlBool
(.||) (Bool -> Field SqlBool
T.sqlBool Bool
False)
(.++) :: F.Field T.SqlText -> F.Field T.SqlText -> F.Field T.SqlText
.++ :: Field SqlText -> Field SqlText -> Field SqlText
(.++) = BinOp -> Column SqlText -> Column SqlText -> Column SqlText
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:||)
lower :: F.Field T.SqlText -> F.Field T.SqlText
lower :: Field SqlText -> Field SqlText
lower = UnOp -> Column SqlText -> Column SqlText
forall a b. UnOp -> Column a -> Column b
C.unOp UnOp
HPQ.OpLower
upper :: F.Field T.SqlText -> F.Field T.SqlText
upper :: Field SqlText -> Field SqlText
upper = UnOp -> Column SqlText -> Column SqlText
forall a b. UnOp -> Column a -> Column b
C.unOp UnOp
HPQ.OpUpper
like :: F.Field T.SqlText -> F.Field T.SqlText -> F.Field T.SqlBool
like :: Field SqlText -> Field SqlText -> Field SqlBool
like = BinOp -> Column SqlText -> Column SqlText -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
HPQ.OpLike
ilike :: F.Field T.SqlText -> F.Field T.SqlText -> F.Field T.SqlBool
ilike :: Field SqlText -> Field SqlText -> Field SqlBool
ilike = BinOp -> Column SqlText -> Column SqlText -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
HPQ.OpILike
charLength :: C.PGString a => Column a -> Column Int
charLength :: Column a -> Column Int
charLength (Column PrimExpr
e) = PrimExpr -> Column Int
forall pgType. PrimExpr -> Column pgType
Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"char_length" [PrimExpr
e])
sqlLength :: C.PGString a => F.Field a -> F.Field T.SqlInt4
sqlLength :: Field a -> Field SqlInt4
sqlLength (Column e) = PrimExpr -> Column SqlInt4
forall pgType. PrimExpr -> Column pgType
Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"length" [PrimExpr
e])
in_ :: (Functor f, F.Foldable f) => f (Column a) -> Column a -> F.Field T.SqlBool
in_ :: f (Column a) -> Column a -> Field SqlBool
in_ f (Column a)
fcas (Column PrimExpr
a) = PrimExpr -> Column SqlBool
forall pgType. PrimExpr -> Column pgType
Column (PrimExpr -> Column SqlBool) -> PrimExpr -> Column SqlBool
forall a b. (a -> b) -> a -> b
$ case [Column a] -> Maybe (NonEmpty (Column a))
forall a. [a] -> Maybe (NonEmpty a)
NEL.nonEmpty (f (Column a) -> [Column a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList f (Column a)
fcas) of
Maybe (NonEmpty (Column a))
Nothing -> Literal -> PrimExpr
HPQ.ConstExpr (Bool -> Literal
HPQ.BoolLit Bool
False)
Just NonEmpty (Column a)
xs -> BinOp -> PrimExpr -> PrimExpr -> PrimExpr
HPQ.BinExpr BinOp
HPQ.OpIn PrimExpr
a (NonEmpty PrimExpr -> PrimExpr
HPQ.ListExpr ((Column a -> PrimExpr) -> NonEmpty (Column a) -> NonEmpty PrimExpr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Column a -> PrimExpr
forall a. Column a -> PrimExpr
C.unColumn NonEmpty (Column a)
xs))
inSelect :: D.Default O.EqPP fields fields
=> fields -> S.Select fields -> S.Select (F.Field T.SqlBool)
inSelect :: fields -> Select fields -> Select (Field SqlBool)
inSelect fields
c Select fields
q = Select fields -> Select (Field SqlBool)
forall a. Select a -> Select (Field SqlBool)
E.exists ((fields -> Field SqlBool) -> SelectArr fields fields
forall a. (a -> Field SqlBool) -> SelectArr a a
keepWhen (fields
c fields -> fields -> Field SqlBool
forall fields.
Default EqPP fields fields =>
fields -> fields -> Field SqlBool
.===) SelectArr fields fields -> Select fields -> Select fields
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
A.<<< Select fields
q)
class SqlIsJson a
{-# DEPRECATED PGIsJson "Use SqlIsJson instead" #-}
type PGIsJson = SqlIsJson
instance SqlIsJson T.SqlJson
instance SqlIsJson T.SqlJsonb
class SqlJsonIndex a
type PGJsonIndex = SqlJsonIndex
instance SqlJsonIndex T.SqlInt4
instance SqlJsonIndex T.SqlInt8
instance SqlJsonIndex T.SqlText
infixl 8 .->
(.->) :: (SqlIsJson a, SqlJsonIndex k)
=> F.FieldNullable a
-> F.Field k
-> F.FieldNullable a
.-> :: FieldNullable a -> Field k -> FieldNullable a
(.->) = BinOp -> Column (Nullable a) -> Column k -> Column (Nullable a)
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:->)
infixl 8 .->>
(.->>) :: (SqlIsJson a, SqlJsonIndex k)
=> F.FieldNullable a
-> F.Field k
-> F.FieldNullable T.SqlText
.->> :: FieldNullable a -> Field k -> FieldNullable SqlText
(.->>) = BinOp
-> Column (Nullable a) -> Column k -> Column (Nullable SqlText)
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:->>)
infixl 8 .#>
(.#>) :: (SqlIsJson a)
=> F.FieldNullable a
-> Column (T.SqlArray T.SqlText)
-> F.FieldNullable a
.#> :: FieldNullable a -> Column (SqlArray SqlText) -> FieldNullable a
(.#>) = BinOp
-> Column (Nullable a)
-> Column (SqlArray SqlText)
-> Column (Nullable a)
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:#>)
infixl 8 .#>>
(.#>>) :: (SqlIsJson a)
=> F.FieldNullable a
-> Column (T.SqlArray T.SqlText)
-> F.FieldNullable T.SqlText
.#>> :: FieldNullable a
-> Column (SqlArray SqlText) -> FieldNullable SqlText
(.#>>) = BinOp
-> Column (Nullable a)
-> Column (SqlArray SqlText)
-> Column (Nullable SqlText)
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:#>>)
infix 4 .@>
(.@>) :: F.Field T.SqlJsonb -> F.Field T.SqlJsonb -> F.Field T.SqlBool
.@> :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
(.@>) = BinOp -> Column SqlJsonb -> Column SqlJsonb -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:@>)
infix 4 .<@
(.<@) :: F.Field T.SqlJsonb -> F.Field T.SqlJsonb -> F.Field T.SqlBool
.<@ :: Field SqlJsonb -> Field SqlJsonb -> Field SqlBool
(.<@) = BinOp -> Column SqlJsonb -> Column SqlJsonb -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<@)
infix 4 .?
(.?) :: F.Field T.SqlJsonb -> F.Field T.SqlText -> F.Field T.SqlBool
.? :: Field SqlJsonb -> Field SqlText -> Field SqlBool
(.?) = BinOp -> Column SqlJsonb -> Column SqlText -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:?)
infix 4 .?|
(.?|) :: F.Field T.SqlJsonb
-> Column (T.SqlArray T.SqlText)
-> F.Field T.SqlBool
.?| :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
(.?|) = BinOp
-> Column SqlJsonb -> Column (SqlArray SqlText) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:?|)
infix 4 .?&
(.?&) :: F.Field T.SqlJsonb
-> Column (T.SqlArray T.SqlText)
-> F.Field T.SqlBool
.?& :: Field SqlJsonb -> Column (SqlArray SqlText) -> Field SqlBool
(.?&) = BinOp
-> Column SqlJsonb -> Column (SqlArray SqlText) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:?&)
emptyArray :: T.IsSqlType a => Column (T.SqlArray a)
emptyArray :: Column (SqlArray a)
emptyArray = (Column a -> Field a) -> [Column a] -> Field (SqlArray a)
forall b a.
IsSqlType b =>
(a -> Field b) -> [a] -> Field (SqlArray b)
T.sqlArray Column a -> Field a
forall a. a -> a
id []
arrayAppend :: F.Field (T.SqlArray a) -> F.Field (T.SqlArray a) -> F.Field (T.SqlArray a)
arrayAppend :: Field (SqlArray a) -> Field (SqlArray a) -> Field (SqlArray a)
arrayAppend = BinOp
-> Column (SqlArray a)
-> Column (SqlArray a)
-> Column (SqlArray a)
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:||)
arrayPrepend :: Column a -> Column (T.SqlArray a) -> Column (T.SqlArray a)
arrayPrepend :: Column a -> Column (SqlArray a) -> Column (SqlArray a)
arrayPrepend (Column PrimExpr
e) (Column PrimExpr
es) = PrimExpr -> Column (SqlArray a)
forall pgType. PrimExpr -> Column pgType
Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"array_prepend" [PrimExpr
e, PrimExpr
es])
arrayRemove :: Column a -> Column (T.SqlArray a) -> Column (T.SqlArray a)
arrayRemove :: Column a -> Column (SqlArray a) -> Column (SqlArray a)
arrayRemove (Column PrimExpr
e) (Column PrimExpr
es) = PrimExpr -> Column (SqlArray a)
forall pgType. PrimExpr -> Column pgType
Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"array_remove" [PrimExpr
es, PrimExpr
e])
arrayRemoveNulls :: Column (T.SqlArray (C.Nullable a)) -> Column (T.SqlArray a)
arrayRemoveNulls :: Column (SqlArray (Nullable a)) -> Column (SqlArray a)
arrayRemoveNulls = Column (SqlArray (Nullable a)) -> Column (SqlArray a)
forall a b. Column a -> Column b
Column.unsafeCoerceColumn (Column (SqlArray (Nullable a)) -> Column (SqlArray a))
-> (Column (SqlArray (Nullable a))
-> Column (SqlArray (Nullable a)))
-> Column (SqlArray (Nullable a))
-> Column (SqlArray a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Column (Nullable a)
-> Column (SqlArray (Nullable a)) -> Column (SqlArray (Nullable a))
forall a. Column a -> Column (SqlArray a) -> Column (SqlArray a)
arrayRemove Column (Nullable a)
forall a. Column (Nullable a)
Column.null
singletonArray :: T.IsSqlType a => Column a -> Column (T.SqlArray a)
singletonArray :: Column a -> Column (SqlArray a)
singletonArray Column a
x = Column a -> Column (SqlArray a) -> Column (SqlArray a)
forall a. Column a -> Column (SqlArray a) -> Column (SqlArray a)
arrayPrepend Column a
x Column (SqlArray a)
forall a. IsSqlType a => Column (SqlArray a)
emptyArray
index :: (C.SqlIntegral n) => Column (T.SqlArray a) -> Column n -> Column (C.Nullable a)
index :: Column (SqlArray a) -> Column n -> Column (Nullable a)
index (Column PrimExpr
a) (Column PrimExpr
b) = PrimExpr -> Column (Nullable a)
forall pgType. PrimExpr -> Column pgType
Column (PrimExpr -> PrimExpr -> PrimExpr
HPQ.ArrayIndex PrimExpr
a PrimExpr
b)
arrayPosition :: F.Field (T.SqlArray a)
-> F.Field a
-> F.Field (Column.Nullable T.SqlInt4)
arrayPosition :: Field (SqlArray a) -> Field a -> Field (Nullable SqlInt4)
arrayPosition (Column fs) (Column f') =
PrimExpr -> Column (Nullable SqlInt4)
forall pgType. PrimExpr -> Column pgType
C.Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"array_position" [PrimExpr
fs , PrimExpr
f'])
sqlElem :: F.Field a
-> F.Field (T.SqlArray a)
-> F.Field T.SqlBool
sqlElem :: Field a -> Field (SqlArray a) -> Field SqlBool
sqlElem Field a
f Field (SqlArray a)
fs = (Column SqlBool -> Column SqlBool
Field SqlBool -> Field SqlBool
O.not (Column SqlBool -> Column SqlBool)
-> (Column a -> Column SqlBool) -> Column a -> Column SqlBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Column (Nullable SqlInt4) -> Column SqlBool
forall a. FieldNullable a -> Field SqlBool
F.isNull (Column (Nullable SqlInt4) -> Column SqlBool)
-> (Column a -> Column (Nullable SqlInt4))
-> Column a
-> Column SqlBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Field (SqlArray a) -> Field a -> Field (Nullable SqlInt4)
forall a. Field (SqlArray a) -> Field a -> Field (Nullable SqlInt4)
arrayPosition Field (SqlArray a)
fs) Column a
Field a
f
overlap :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
overlap :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
overlap = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:&&)
liesWithin :: T.IsRangeType a => Column a -> Column (T.SqlRange a) -> F.Field T.SqlBool
liesWithin :: Column a -> Column (SqlRange a) -> Field SqlBool
liesWithin = BinOp -> Column a -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<@)
upperBound :: T.IsRangeType a => Column (T.SqlRange a) -> Column (C.Nullable a)
upperBound :: Column (SqlRange a) -> Column (Nullable a)
upperBound (Column PrimExpr
range) = PrimExpr -> Column (Nullable a)
forall pgType. PrimExpr -> Column pgType
Column (PrimExpr -> Column (Nullable a))
-> PrimExpr -> Column (Nullable a)
forall a b. (a -> b) -> a -> b
$ Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"upper" [PrimExpr
range]
lowerBound :: T.IsRangeType a => Column (T.SqlRange a) -> Column (C.Nullable a)
lowerBound :: Column (SqlRange a) -> Column (Nullable a)
lowerBound (Column PrimExpr
range) = PrimExpr -> Column (Nullable a)
forall pgType. PrimExpr -> Column pgType
Column (PrimExpr -> Column (Nullable a))
-> PrimExpr -> Column (Nullable a)
forall a b. (a -> b) -> a -> b
$ Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"lower" [PrimExpr
range]
infix 4 .<<
(.<<) :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
.<< :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
(.<<) = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:<<)
infix 4 .>>
(.>>) :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
.>> :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
(.>>) = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:>>)
infix 4 .&<
(.&<) :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
.&< :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
(.&<) = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:&<)
infix 4 .&>
(.&>) :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
.&> :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
(.&>) = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:&>)
infix 4 .-|-
(.-|-) :: Column (T.SqlRange a) -> Column (T.SqlRange a) -> F.Field T.SqlBool
.-|- :: Column (SqlRange a) -> Column (SqlRange a) -> Field SqlBool
(.-|-) = BinOp
-> Column (SqlRange a) -> Column (SqlRange a) -> Column SqlBool
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
(HPQ.:-|-)
timestamptzAtTimeZone :: F.Field T.SqlTimestamptz
-> F.Field T.SqlText
-> F.Field T.SqlTimestamp
timestamptzAtTimeZone :: Field SqlTimestamptz -> Field SqlText -> Field SqlTimestamp
timestamptzAtTimeZone = BinOp
-> Column SqlTimestamptz -> Column SqlText -> Column SqlTimestamp
forall a b c. BinOp -> Column a -> Column b -> Column c
C.binOp BinOp
HPQ.OpAtTimeZone
dateOfTimestamp :: F.Field T.SqlTimestamp -> F.Field T.SqlDate
dateOfTimestamp :: Field SqlTimestamp -> Field SqlDate
dateOfTimestamp (Column e) = PrimExpr -> Column SqlDate
forall pgType. PrimExpr -> Column pgType
Column (Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"date" [PrimExpr
e])
{-# DEPRECATED exists "Identical to 'restrictExists'. Will be removed in version 0.8." #-}
exists :: QueryArr a b -> QueryArr a ()
exists :: QueryArr a b -> QueryArr a ()
exists = QueryArr a b -> QueryArr a ()
forall a b. SelectArr a b -> SelectArr a ()
restrictExists
{-# DEPRECATED notExists "Identical to 'restrictNotExists'. Will be removed in version 0.8." #-}
notExists :: QueryArr a b -> QueryArr a ()
notExists :: QueryArr a b -> QueryArr a ()
notExists = QueryArr a b -> QueryArr a ()
forall a b. SelectArr a b -> SelectArr a ()
restrictNotExists
{-# DEPRECATED inQuery "Identical to 'inSelect'. Will be removed in version 0.8." #-}
inQuery :: D.Default O.EqPP fields fields
=> fields -> Query fields -> S.Select (F.Field T.SqlBool)
inQuery :: fields -> Query fields -> Select (Field SqlBool)
inQuery = fields -> Query fields -> Select (Field SqlBool)
forall fields.
Default EqPP fields fields =>
fields -> Select fields -> Select (Field SqlBool)
inSelect
keepWhen :: (a -> F.Field T.SqlBool) -> S.SelectArr a a
keepWhen :: (a -> Field SqlBool) -> SelectArr a a
keepWhen a -> Field SqlBool
p = proc a
a -> do
SelectArr (Column SqlBool) ()
SelectArr (Field SqlBool) ()
restrict -< a -> Field SqlBool
p a
a
SelectArr a a
forall (a :: * -> * -> *) b. Arrow a => a b b
A.returnA -< a
a
now :: F.Field T.SqlTimestamptz
now :: Field SqlTimestamptz
now = PrimExpr -> Column SqlTimestamptz
forall pgType. PrimExpr -> Column pgType
Column (PrimExpr -> Column SqlTimestamptz)
-> PrimExpr -> Column SqlTimestamptz
forall a b. (a -> b) -> a -> b
$ Name -> [PrimExpr] -> PrimExpr
HPQ.FunExpr Name
"now" []