cake/combined
A DSL to build combined queries, such as:
UNION
UNION ALL
EXCEPT
EXCEPT ALL
INTERSECT
INTERSECT ALL
Compatibility
- 🪶SQLite does not support
EXCEPT ALL
andINTERSECT ALL
.
Types
Defines the direction of an OrderBy
.
pub type Direction {
Asc
Desc
}
Constructors
-
Asc
-
Desc
pub type OrderByDirection =
read_query.OrderByDirection
Functions
pub fn comment(
query qry: Combined,
comment cmmnt: String,
) -> Combined
Appends a Comment
to the Combined
read_query.
pub fn epilog(
query qry: Combined,
epilog eplg: String,
) -> Combined
Appends an Epilog
to the Combined
read_query.
pub fn except(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates an EXCEPT
query out of two queries as a Combined
ReadQuery
.
pub fn except_all(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates an EXCEPT ALL
query out of two queries as a Combined
ReadQuery
.
NOTICE: Not supported by 🪶SQLite.
pub fn excepts(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates an EXCEPT
query out of two or more queries as a Combined
ReadQuery
.
pub fn excepts_all(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates an EXCEPT ALL
query out of two or more queries as a Combined
ReadQuery
.
NOTICE: Not supported by 🪶SQLite.
pub fn get_comment(query qry: Combined) -> Comment
Gets the Comment
from the Combined
read_query.
pub fn get_epilog(query qry: Combined) -> Epilog
Gets the Epilog
from the Combined
read_query.
pub fn get_offset(query qry: Combined) -> Offset
Gets Offset
in the Combined
ReadQuery
.
pub fn get_order_by(query qry: Combined) -> OrderBy
Gets the OrderBy
from the Combined
read_query.
pub fn get_queries(combined cmbnd: Combined) -> List(Select)
Gets the queries from a Combined
ReadQuery
.
pub fn intersect(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates an INTERSECT
query out of two queries as a Combined
ReadQuery
.
pub fn intersect_all(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates an INTERSECT ALL
query out of two queries as a Combined
ReadQuery
.
NOTICE: Not supported by 🪶SQLite.
pub fn intersects(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates an INTERSECT
query out of two or more queries as a Combined
read_query.
pub fn intersects_all(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates an INTERSECT ALL
query out of two or more queries as a Combined
ReadQuery
.
NOTICE: Not supported by 🪶SQLite.
pub fn limit(query qry: Combined, limit lmt: Int) -> Combined
Sets a Limit
in the Combined
ReadQuery
.
pub fn no_comment(query qry: Combined) -> Combined
Removes the Comment
from the Combined
read_query.
pub fn no_epilog(query qry: Combined) -> Combined
Removes the Epilog
from the Combined
read_query.
pub fn no_limit(query qry: Combined) -> Combined
Removes Limit
from the Combined
ReadQuery
.
pub fn no_offset(query qry: Combined) -> Combined
Removes Offset
from the Combined
ReadQuery
.
pub fn no_order_by(query qry: Combined) -> Combined
Removes the OrderBy
from the Combined
read_query.
pub fn offset(query qry: Combined, offst offst: Int) -> Combined
Sets an Offset
in the Combined
ReadQuery
.
pub fn order_by(
query qry: Combined,
by ordb: String,
direction dir: Direction,
) -> Combined
Creates or appends an OrderBy
a column with a direction.
The direction can either ASC
or DESC
.
pub fn order_by_asc(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends an ascending OrderBy
.
pub fn order_by_asc_nulls_first(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends an ascending OrderBy
with NULLS FIRST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS FIRST
out of the box.
pub fn order_by_asc_nulls_last(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends an ascending OrderBy
with NULLS LAST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS LAST
out of the box.
pub fn order_by_desc(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends a descending OrderBy
.
pub fn order_by_desc_nulls_first(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends a descending order with NULLS FIRST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS FIRST
out of the box.
pub fn order_by_desc_nulls_last(
query qry: Combined,
by ordb: String,
) -> Combined
Creates or appends a descending OrderBy
with NULLS LAST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS LAST
out of the box.
pub fn replace_order_by(
query qry: Combined,
by ordb: String,
direction dir: Direction,
) -> Combined
Replaces the OrderBy
a column with a direction.
pub fn replace_order_by_asc(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single ascending OrderBy
.
pub fn replace_order_by_asc_nulls_first(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single ascending OrderBy
with NULLS FIRST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS FIRST
out of the box.
pub fn replace_order_by_asc_nulls_last(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single ascending OrderBy
with NULLS LAST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS LAST
out of the box.
pub fn replace_order_by_desc(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single descending order.
pub fn replace_order_by_desc_nulls_first(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single descending order with NULLS FIRST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS FIRST
out of the box.
pub fn replace_order_by_desc_nulls_last(
query qry: Combined,
by ordb: String,
) -> Combined
Replaces the OrderBy
a single descending OrderBy
with NULLS LAST
.
NOTICE: 🦭MariaDB and 🐬MySQL do not support NULLS LAST
out of the box.
pub fn to_query(combined cmbnd: Combined) -> ReadQuery
Creates a ReadQuery
from a Combined
read_query.
pub fn union(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates a UNION
query out of two queries as a Combined
ReadQuery
.
pub fn union_all(
query_a qry_a: Select,
query_b qry_b: Select,
) -> Combined
Creates a UNION ALL
query out of two queries as a Combined
ReadQuery
.
pub fn unions(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates a UNION
query out of two or more queries as a Combined
ReadQuery
.
pub fn unions_all(
query_a qry_a: Select,
query_b qry_b: Select,
more_queries mr_qrys: List(Select),
) -> Combined
Creates a UNION ALL
query out of two or more queries as a Combined
ReadQuery
.
NOTICE: Not supported by 🪶SQLite.