cake/update
A DSL to build UPDATE
queries.
Types
pub type UpdateSets =
write_query.UpdateSets
pub type UpdateTable =
write_query.UpdateTable
pub type WriteQuery(a) =
write_query.WriteQuery(a)
Functions
pub fn comment(
update updt: Update(a),
comment cmmnt: String,
) -> Update(a)
Sets a Comment
or appends into an existing Comment
.
pub fn epilog(
update updt: Update(a),
epilog eplg: String,
) -> Update(a)
Sets an Epilog
or appends into an existing Epilog
.
pub fn from_sub_query(
update updt: Update(a),
query qry: ReadQuery,
alias als: String,
) -> Update(a)
Sets the FROM
clause of the Update
query to an aliased sub-query.
pub fn from_table(
update updt: Update(a),
name tbl_nm: String,
) -> Update(a)
Sets the FROM
clause of the Update
query to a table name.
pub fn get_comment(update updt: Update(a)) -> Comment
Gets the Comment
of the Update
query.
pub fn get_epilog(update updt: Update(a)) -> Epilog
Gets the Epilog
of the Update
query.
pub fn get_from(update updt: Update(a)) -> From
Gets the FROM
clause of the Update
query.
pub fn get_set(update updt: Update(a)) -> List(UpdateSet)
Get the SET
s of the Update
query.
pub fn get_table(update updt: Update(a)) -> UpdateTable
Get the table of the Update
query.
pub fn join(update updt: Update(a), join jn: Join) -> Update(a)
Adds a Join
to the Update
query.
NOTICE: On 🐘PostgreSQL and 🪶SQLite Joins
are only allowed if the FROM
clause is set as well.
pub fn joins(
update updt: Update(a),
joins jns: List(Join),
) -> Update(a)
Adds Join
s to the Update
query.
NOTICE: On 🐘PostgreSQL and 🪶SQLite Joins
are only allowed if the FROM
clause is set as well.
pub fn no_comment(update updt: Update(a)) -> Update(a)
Removes the Comment
from the Update
query.
pub fn no_epilog(update updt: Update(a)) -> Update(a)
Removes the Epilog
from the Update
query.
pub fn no_from(update updt: Update(a)) -> Update(a)
Removes the FROM
clause of the Update
query.
pub fn no_join(update updt: Update(a)) -> Update(a)
Removes any Joins
from the Update
query.
pub fn no_returning(update updt: Update(a)) -> Update(a)
NOTICE: 🦭MariaDB and 🐬MySQL do not support RETURNING
in UPDATE
queries; they do support it in INSERT
(and REPLACE
) queries, however.
pub fn no_where(update updt: Update(a)) -> Update(a)
Removes the Where
from the Update
query.
pub fn or_where(
update updt: Update(a),
where whr: Where,
) -> Update(a)
Sets an OrWhere
or appends into an existing OrWhere
.
- If the outermost
Where
is anOrWhere
, the newWhere
is appended to the list withinOrWhere
. - If the query does not have a
Where
clause, the givenWhere
is set instead. - If the outermost
Where
is any other kind ofWhere
, this and the current outermostWhere
are wrapped in anOrWhere
.
pub fn replace_join(
update updt: Update(a),
join jn: Join,
) -> Update(a)
Replaces any Join
s of the Update
query with a signle Join
.
NOTICE: On 🐘PostgreSQL and 🪶SQLite Joins
are only allowed if the FROM
clause is set as well.
pub fn replace_joins(
update updt: Update(a),
joins jns: List(Join),
) -> Update(a)
Replaces any Join
s of the Update
query with the given Join
s.
NOTICE: On 🐘PostgreSQL and 🪶SQLite Joins
are only allowed if the FROM
clause is set as well.
pub fn replace_where(
update updt: Update(a),
where whr: Where,
) -> Update(a)
Replaces the Where
in the Update
query.
pub fn returning(
update updt: Update(a),
returning rtrn: List(String),
) -> Update(a)
NOTICE: 🦭MariaDB and 🐬MySQL do not support RETURNING
in UPDATE
queries; they do support it in INSERT
(and REPLACE
) queries, however.
pub fn set(
update updt: Update(a),
set st: UpdateSet,
) -> Update(a)
Sets or appends one column set in an Update
query.
pub fn set_bool(column col: String, value v: Bool) -> UpdateSet
Sets a column to a Bool
UpdateParamSet
.
pub fn set_expression(
column col: String,
expression exp: String,
) -> UpdateSet
Sets a column to an expression value.
pub fn set_false(column col: String) -> UpdateSet
Sets a column to a False
UpdateParamSet
.
pub fn set_float(column col: String, value v: Float) -> UpdateSet
Sets a column to a Float
UpdateParamSet
.
pub fn set_int(column col: String, value v: Int) -> UpdateSet
Sets a column to a Int
UpdateParamSet
.
pub fn set_null(column col: String) -> UpdateSet
Sets a column to an SQL NULL
UpdateParamSet
.
pub fn set_replace(
update updt: Update(a),
set st: UpdateSet,
) -> Update(a)
Sets or replaces one column set in an Update
query.
pub fn set_string(
column col: String,
value v: String,
) -> UpdateSet
Sets a column to a string UpdateParamSet
.
pub fn set_sub_query(
column col: String,
query qry: ReadQuery,
) -> UpdateSet
Sets a column to a sub-query value.
pub fn set_true(column col: String) -> UpdateSet
Sets a column to a True
UpdateParamSet
.
pub fn sets(
update updt: Update(a),
set sts: List(UpdateSet),
) -> Update(a)
Sets or appends many column sets n an Update
query.
pub fn sets_expression(
columns cols: List(String),
expression exp: String,
) -> UpdateSet
Sets many columns to an expression value.
NOTICE: the expression must return an equal count of columns.
pub fn sets_replace(
update updt: Update(a),
sets sts: List(UpdateSet),
) -> Update(a)
Sets or replaces many column sets in an Update
query.
pub fn sets_sub_query(
columns cols: List(String),
query qry: ReadQuery,
) -> UpdateSet
Sets many columns to a sub-query value.
NOTICE: the sub-query must return an equal count of columns.
pub fn table(
update updt: Update(a),
table_name tbl_nm: String,
) -> Update(a)
Sets the table of the Update
query.
pub fn to_query(update updt: Update(a)) -> WriteQuery(a)
Creates a WriteQuery
from an Update
query.
pub fn where(
update updt: Update(a),
where whr: Where,
) -> Update(a)
Sets an AndWhere
or appends into an existing AndWhere
.
- If the outermost
Where
is anAndWhere
, the newWhere
is appended to the list withinAndWhere
. - If the query does not have a
Where
clause, the givenWhere
is set instead. - If the outermost
Where
is any other kind ofWhere
, this and the current outermostWhere
are wrapped in anAndWhere
.
pub fn xor_where(
update updt: Update(a),
where whr: Where,
) -> Update(a)
Sets an XorWhere
or appends into an existing XorWhere
.
- If the outermost
Where
is anXorWhere
, the newWhere
is appended to the list withinXorWhere
. - If the query does not have a
Where
clause, the givenWhere
is set instead. - If the outermost
Where
is any other kind ofWhere
, this and the current outermostWhere
are wrapped in anXorWhere
.
NOTICE: This operator does not exist in 🐘PostgreSQL or 🪶SQLite,
and Cake generates equivalent SQL using OR
and AND
and NOT
.
NOTICE: This operator exists in 🦭MariaDB and 🐬MySQL with native support.