Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Squeal joins
Synopsis
- data JoinItem (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType) where
- Join :: FromClause lat with db params right -> JoinItem lat with db params left right
- JoinLateral :: Aliased (Query (Join lat left) with db params) query -> JoinItem lat with db params left '[query]
- JoinFunction :: SetFun db arg set -> Expression 'Ungrouped lat with db params left arg -> JoinItem lat with db params left '[set]
- JoinFunctionN :: SListI args => SetFunN db args set -> NP (Expression 'Ungrouped lat with db params left) args -> JoinItem lat with db params left '[set]
- cross :: JoinItem lat with db params left right -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- crossJoin :: FromClause lat with db params right -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- crossJoinLateral :: Aliased (Query (Join lat left) with db params) query -> FromClause lat with db params left -> FromClause lat with db params (Join left '[query])
- inner :: JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- innerJoin :: FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- innerJoinLateral :: Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join left '[query])
- leftOuter :: JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom right))
- leftOuterJoin :: FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom right))
- leftOuterJoinLateral :: Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom '[query]))
- rightOuter :: JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) right)
- rightOuterJoin :: FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) right)
- rightOuterJoinLateral :: Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) '[query])
- fullOuter :: JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left right))
- fullOuterJoin :: FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left right))
- fullOuterJoinLateral :: Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left '[query]))
Join
data JoinItem (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType) where Source #
A JoinItem
is the right hand side of a cross
,
inner
, leftOuter
, rightOuter
, fullOuter
join of
FromClause
s.
Join | |
| |
JoinLateral | |
| |
JoinFunction | |
| |
JoinFunctionN | |
|
Instances
RenderSQL (JoinItem lat with db params left right) Source # | |
Defined in Squeal.PostgreSQL.Query.From.Join renderSQL :: JoinItem lat with db params left right -> ByteString Source # |
:: JoinItem lat with db params left right | right |
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left right) |
left & cross (Join right)
. For every possible combination of rows from
left
and right
(i.e., a Cartesian product), the joined table will contain
a row consisting of all columns in left
followed by all columns in right
.
If the tables have n
and m
rows respectively, the joined table will
have n * m
rows.
:: FromClause lat with db params right | right |
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left right) |
left & crossJoin right
. For every possible combination of rows from
left
and right
(i.e., a Cartesian product), the joined table will contain
a row consisting of all columns in left
followed by all columns in right
.
If the tables have n
and m
rows respectively, the joined table will
have n * m
rows.
:: Aliased (Query (Join lat left) with db params) query | right subquery |
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left '[query]) |
Like crossJoin
with a subquery
but allowed to reference columns provided
by preceding FromClause
items.
:: JoinItem lat with db params left right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left right) |
left & inner (Join right) on
. The joined table is filtered by
the on
condition.
:: FromClause lat with db params right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left right) |
left & innerJoin right on
. The joined table is filtered by
the on
condition.
:: Aliased (Query (Join lat left) with db params) query | right subquery |
-> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left '[query]) |
Like innerJoin
with a subquery
but allowed to reference columns provided
by preceding FromClause
items.
:: JoinItem lat with db params left right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left (NullifyFrom right)) |
left & leftOuter (Join right) on
. First, an inner join is performed.
Then, for each row in left
that does not satisfy the on
condition with
any row in right
, a joined row is added with null values in columns of right
.
Thus, the joined table always has at least one row for each row in left
.
:: FromClause lat with db params right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left (NullifyFrom right)) |
left & leftOuterJoin right on
. First, an inner join is performed.
Then, for each row in left
that does not satisfy the on
condition with
any row in right
, a joined row is added with null values in columns of right
.
Thus, the joined table always has at least one row for each row in left
.
:: Aliased (Query (Join lat left) with db params) query | right subquery |
-> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join left (NullifyFrom '[query])) |
Like leftOuterJoin
with a subquery
but allowed to reference columns provided
by preceding FromClause
items.
:: JoinItem lat with db params left right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join (NullifyFrom left) right) |
left & rightOuter (Join right) on
. First, an inner join is performed.
Then, for each row in right
that does not satisfy the on
condition with
any row in left
, a joined row is added with null values in columns of left
.
This is the converse of a left join: the result table will always
have a row for each row in right
.
:: FromClause lat with db params right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join (NullifyFrom left) right) |
left & rightOuterJoin right on
. First, an inner join is performed.
Then, for each row in right
that does not satisfy the on
condition with
any row in left
, a joined row is added with null values in columns of left
.
This is the converse of a left join: the result table will always
have a row for each row in right
.
rightOuterJoinLateral Source #
:: Aliased (Query (Join lat left) with db params) query | right subquery |
-> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (Join (NullifyFrom left) '[query]) |
Like rightOuterJoin
with a subquery
but allowed to reference columns provided
by preceding FromClause
items.
:: JoinItem lat with db params left right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (NullifyFrom (Join left right)) |
left & fullOuter (Join right) on
. First, an inner join is performed.
Then, for each row in left
that does not satisfy the on
condition with
any row in right
, a joined row is added with null values in columns of right
.
Also, for each row of right
that does not satisfy the join condition
with any row in left
, a joined row with null values in the columns of left
is added.
:: FromClause lat with db params right | right |
-> Condition 'Ungrouped lat with db params (Join left right) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (NullifyFrom (Join left right)) |
left & fullOuterJoin right on
. First, an inner join is performed.
Then, for each row in left
that does not satisfy the on
condition with
any row in right
, a joined row is added with null values in columns of right
.
Also, for each row of right
that does not satisfy the join condition
with any row in left
, a joined row with null values in the columns of left
is added.
:: Aliased (Query (Join lat left) with db params) query | right subquery |
-> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
-> FromClause lat with db params left | left |
-> FromClause lat with db params (NullifyFrom (Join left '[query])) |
Like fullOuterJoin
with a subquery
but allowed to reference columns provided
by preceding FromClause
items.