{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Opaleye.Join where
import qualified Opaleye.Field as F
import qualified Opaleye.Internal.Unpackspec as U
import qualified Opaleye.Internal.Join as J
import qualified Opaleye.Internal.MaybeFields as M
import qualified Opaleye.Internal.PrimQuery as PQ
import qualified Opaleye.Internal.Map as Map
import qualified Opaleye.Select as S
import qualified Opaleye.SqlTypes as T
import qualified Data.Profunctor.Product.Default as D
optional :: D.Default U.Unpackspec a a
=> S.SelectArr i a
-> S.SelectArr i (M.MaybeFields a)
optional :: SelectArr i a -> SelectArr i (MaybeFields a)
optional = SelectArr i a -> SelectArr i (MaybeFields a)
forall i a. SelectArr i a -> SelectArr i (MaybeFields a)
M.optional
optionalRestrict :: D.Default U.Unpackspec a a
=> S.Select a
-> S.SelectArr (a -> F.Field T.SqlBool) (M.MaybeFields a)
optionalRestrict :: Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
optionalRestrict = Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
forall a.
Default Unpackspec a a =>
Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
J.optionalRestrict
leftJoin :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsR nullableFieldsR)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (fieldsL, nullableFieldsR)
leftJoin :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
leftJoin = Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
forall fieldsL fieldsR nullableFieldsR.
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
leftJoinExplicit Unpackspec fieldsL fieldsL
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def Unpackspec fieldsR fieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def NullMaker fieldsR nullableFieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def
leftJoinA :: (D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsR nullableFieldsR)
=> S.Select fieldsR
-> S.SelectArr (fieldsR -> F.Field T.SqlBool) nullableFieldsR
leftJoinA :: Select fieldsR
-> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
leftJoinA = Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsR
-> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
forall fieldsR nullableFieldsR.
Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsR
-> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
leftJoinAExplict Unpackspec fieldsR fieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def NullMaker fieldsR nullableFieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def
rightJoin :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsL nullableFieldsL)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, fieldsR)
rightJoin :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
rightJoin = Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
forall fieldsL fieldsR nullableFieldsL.
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
rightJoinExplicit Unpackspec fieldsL fieldsL
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def Unpackspec fieldsR fieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def NullMaker fieldsL nullableFieldsL
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def
fullJoin :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsL nullableFieldsL,
D.Default J.NullMaker fieldsR nullableFieldsR)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, nullableFieldsR)
fullJoin :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
fullJoin = Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
forall fieldsL fieldsR nullableFieldsL nullableFieldsR.
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
fullJoinExplicit Unpackspec fieldsL fieldsL
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def Unpackspec fieldsR fieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def NullMaker fieldsL nullableFieldsL
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def NullMaker fieldsR nullableFieldsR
forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def
leftJoinExplicit :: U.Unpackspec fieldsL fieldsL
-> U.Unpackspec fieldsR fieldsR
-> J.NullMaker fieldsR nullableFieldsR
-> S.Select fieldsL -> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (fieldsL, nullableFieldsR)
leftJoinExplicit :: Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
leftJoinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB NullMaker fieldsR nullableFieldsR
nullmaker =
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> (fieldsL -> fieldsL)
-> (fieldsR -> nullableFieldsR)
-> JoinType
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Column SqlBool)
-> Select (fieldsL, nullableFieldsR)
forall columnsA columnsB returnedColumnsA returnedColumnsB.
Unpackspec columnsA columnsA
-> Unpackspec columnsB columnsB
-> (columnsA -> returnedColumnsA)
-> (columnsB -> returnedColumnsB)
-> JoinType
-> Query columnsA
-> Query columnsB
-> ((columnsA, columnsB) -> Column SqlBool)
-> Query (returnedColumnsA, returnedColumnsB)
J.joinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB fieldsL -> fieldsL
forall a. a -> a
id (NullMaker fieldsR nullableFieldsR -> fieldsR -> nullableFieldsR
forall a b. NullMaker a b -> a -> b
J.toNullable NullMaker fieldsR nullableFieldsR
nullmaker) JoinType
PQ.LeftJoin
leftJoinAExplict :: U.Unpackspec fieldsR fieldsR
-> J.NullMaker fieldsR nullableFieldsR
-> S.Select fieldsR
-> S.SelectArr (fieldsR -> F.Field T.SqlBool) nullableFieldsR
leftJoinAExplict :: Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsR
-> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
leftJoinAExplict = Unpackspec fieldsR fieldsR
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsR
-> SelectArr (fieldsR -> Field SqlBool) nullableFieldsR
forall a nullableA.
Unpackspec a a
-> NullMaker a nullableA
-> Query a
-> QueryArr (a -> Column SqlBool) nullableA
J.leftJoinAExplicit
rightJoinExplicit :: U.Unpackspec fieldsL fieldsL
-> U.Unpackspec fieldsR fieldsR
-> J.NullMaker fieldsL nullableFieldsL
-> S.Select fieldsL -> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, fieldsR)
rightJoinExplicit :: Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
rightJoinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB NullMaker fieldsL nullableFieldsL
nullmaker =
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> (fieldsL -> nullableFieldsL)
-> (fieldsR -> fieldsR)
-> JoinType
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Column SqlBool)
-> Select (nullableFieldsL, fieldsR)
forall columnsA columnsB returnedColumnsA returnedColumnsB.
Unpackspec columnsA columnsA
-> Unpackspec columnsB columnsB
-> (columnsA -> returnedColumnsA)
-> (columnsB -> returnedColumnsB)
-> JoinType
-> Query columnsA
-> Query columnsB
-> ((columnsA, columnsB) -> Column SqlBool)
-> Query (returnedColumnsA, returnedColumnsB)
J.joinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB (NullMaker fieldsL nullableFieldsL -> fieldsL -> nullableFieldsL
forall a b. NullMaker a b -> a -> b
J.toNullable NullMaker fieldsL nullableFieldsL
nullmaker) fieldsR -> fieldsR
forall a. a -> a
id JoinType
PQ.RightJoin
fullJoinExplicit :: U.Unpackspec fieldsL fieldsL
-> U.Unpackspec fieldsR fieldsR
-> J.NullMaker fieldsL nullableFieldsL
-> J.NullMaker fieldsR nullableFieldsR
-> S.Select fieldsL -> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, nullableFieldsR)
fullJoinExplicit :: Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> NullMaker fieldsL nullableFieldsL
-> NullMaker fieldsR nullableFieldsR
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
fullJoinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB NullMaker fieldsL nullableFieldsL
nullmakerA NullMaker fieldsR nullableFieldsR
nullmakerB =
Unpackspec fieldsL fieldsL
-> Unpackspec fieldsR fieldsR
-> (fieldsL -> nullableFieldsL)
-> (fieldsR -> nullableFieldsR)
-> JoinType
-> Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Column SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
forall columnsA columnsB returnedColumnsA returnedColumnsB.
Unpackspec columnsA columnsA
-> Unpackspec columnsB columnsB
-> (columnsA -> returnedColumnsA)
-> (columnsB -> returnedColumnsB)
-> JoinType
-> Query columnsA
-> Query columnsB
-> ((columnsA, columnsB) -> Column SqlBool)
-> Query (returnedColumnsA, returnedColumnsB)
J.joinExplicit Unpackspec fieldsL fieldsL
uA Unpackspec fieldsR fieldsR
uB (NullMaker fieldsL nullableFieldsL -> fieldsL -> nullableFieldsL
forall a b. NullMaker a b -> a -> b
J.toNullable NullMaker fieldsL nullableFieldsL
nullmakerA) (NullMaker fieldsR nullableFieldsR -> fieldsR -> nullableFieldsR
forall a b. NullMaker a b -> a -> b
J.toNullable NullMaker fieldsR nullableFieldsR
nullmakerB) JoinType
PQ.FullJoin
optionalRestrictExplicit :: U.Unpackspec a a
-> S.Select a
-> S.SelectArr (a -> F.Field T.SqlBool) (M.MaybeFields a)
optionalRestrictExplicit :: Unpackspec a a
-> Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
optionalRestrictExplicit = Unpackspec a a
-> Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
forall a.
Unpackspec a a
-> Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
J.optionalRestrictExplicit
optionalExplicit :: U.Unpackspec a a
-> S.SelectArr i a
-> S.SelectArr i (M.MaybeFields a)
optionalExplicit :: Unpackspec a a -> SelectArr i a -> SelectArr i (MaybeFields a)
optionalExplicit Unpackspec a a
_ = SelectArr i a -> SelectArr i (MaybeFields a)
forall i a. SelectArr i a -> SelectArr i (MaybeFields a)
M.optional
{-# DEPRECATED leftJoinInferrable "Use 'optionalRestrict' instead." #-}
leftJoinInferrable :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsR nullableFieldsR,
Map.Map J.Nulled fieldsR ~ nullableFieldsR)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (fieldsL, nullableFieldsR)
leftJoinInferrable :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
leftJoinInferrable = Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
forall fieldsL fieldsR nullableFieldsR.
(Default Unpackspec fieldsL fieldsL,
Default Unpackspec fieldsR fieldsR,
Default NullMaker fieldsR nullableFieldsR) =>
Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (fieldsL, nullableFieldsR)
leftJoin
{-# DEPRECATED rightJoinInferrable "Use 'optionalRestrict' instead." #-}
rightJoinInferrable :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsL nullableFieldsL,
Map.Map J.Nulled fieldsL ~ nullableFieldsL)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, fieldsR)
rightJoinInferrable :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
rightJoinInferrable = Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
forall fieldsL fieldsR nullableFieldsL.
(Default Unpackspec fieldsL fieldsL,
Default Unpackspec fieldsR fieldsR,
Default NullMaker fieldsL nullableFieldsL) =>
Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, fieldsR)
rightJoin
{-# DEPRECATED fullJoinInferrable "Use 'Opaleye.FunctionalJoin.rightJoinF' instead." #-}
fullJoinInferrable :: (D.Default U.Unpackspec fieldsL fieldsL,
D.Default U.Unpackspec fieldsR fieldsR,
D.Default J.NullMaker fieldsL nullableFieldsL,
D.Default J.NullMaker fieldsR nullableFieldsR,
Map.Map J.Nulled fieldsL ~ nullableFieldsL,
Map.Map J.Nulled fieldsR ~ nullableFieldsR)
=> S.Select fieldsL
-> S.Select fieldsR
-> ((fieldsL, fieldsR) -> F.Field T.SqlBool)
-> S.Select (nullableFieldsL, nullableFieldsR)
fullJoinInferrable :: Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
fullJoinInferrable = Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
forall fieldsL fieldsR nullableFieldsL nullableFieldsR.
(Default Unpackspec fieldsL fieldsL,
Default Unpackspec fieldsR fieldsR,
Default NullMaker fieldsL nullableFieldsL,
Default NullMaker fieldsR nullableFieldsR) =>
Select fieldsL
-> Select fieldsR
-> ((fieldsL, fieldsR) -> Field SqlBool)
-> Select (nullableFieldsL, nullableFieldsR)
fullJoin