cake/update

A DSL to build UPDATE queries.

Functions

pub fn bool(value vl: Bool) -> Param

Creates a Param from a Bool.

pub fn comment(
  query qry: Update(a),
  comment cmmnt: String,
) -> Update(a)

Sets a Comment or appends into an existing Comment.

pub fn epilog(
  query qry: Update(a),
  epilog eplg: String,
) -> Update(a)

Sets an Epilog or appends into an existing Epilog.

pub fn float(value vl: Float) -> Param

Creates a Param from a Float.

pub fn from_sub_query(
  query qry: Update(a),
  sub_query sb_qry: Query,
  alias als: String,
) -> Update(a)

Sets the FROM clause of the Update query to an aliased sub-query.

pub fn from_table(
  query qry: Update(a),
  name tbl_nm: String,
) -> Update(a)

Sets the FROM clause of the Update query to a table name.

pub fn get_comment(query qry: Update(a)) -> Comment

Gets the Comment of the Update query.

pub fn get_epilog(query qry: Update(a)) -> Epilog

Gets the Epilog of the Update query.

pub fn get_from(query qry: Update(a)) -> From

Gets the FROM clause of the Update query.

pub fn get_joins(query qry: Update(a)) -> Joins

Gets the Joins of the Update query.

pub fn get_set(query qry: Update(a)) -> List(UpdateSet)

Get the sets of the Update query.

pub fn get_table(query qry: Update(a)) -> UpdateTable

Get the table of the Update query.

pub fn get_where(query qry: Update(a)) -> Where

Gets the Where of the Update query.

pub fn int(value vl: Int) -> Param

Creates a Param from an Int.

pub fn join(query qry: Update(a), join jn: Join) -> Update(a)

Adds a Join to the Update query.

NOTICE: On Postgres/SQLite Joins are only allowed if the FROM clause is set as well.

pub fn joins(
  query qry: Update(a),
  joins jns: List(Join),
) -> Update(a)

Adds Joins to the Update query.

NOTICE: On Postgres/SQLite Joins are only allowed if the FROM clause is set as well.

pub fn new() -> Update(a)

Creates an empty Update query.

pub fn no_comment(query qry: Update(a)) -> Update(a)

Removes the Comment from the Update query.

pub fn no_epilog(query qry: Update(a)) -> Update(a)

Removes the Epilog from the Update query.

pub fn no_from(query qry: Update(a)) -> Update(a)

Removes the FROM clause of the Update query.

pub fn no_join(query qry: Update(a)) -> Update(a)

Removes any Joins from the Update query.

pub fn no_returning(query qry: Update(a)) -> Update(a)

NOTICE: MariaDB/MySQL do not support RETURNING in UPDATE queries; they do support it in INSERT (and REPLACE) queries, however.

pub fn no_where(query qry: Update(a)) -> Update(a)

Removes the Where from the Update query.

pub fn or_where(
  query qry: Update(a),
  where whr: Where,
) -> Update(a)

Sets an OrWhere or appends into an existing OrWhere.

  • If the outermost Where is an OrWhere, the new Where is appended to the list within OrWhere.
  • If the query does not have a Where clause, the given Where is set instead.
  • If the outermost Where is any other kind of Where, this and the current outermost Where are wrapped in an OrWhere.
pub fn replace_join(
  query qry: Update(a),
  join jn: Join,
) -> Update(a)

Replaces any Joins of the Update query with a signle Join.

NOTICE: On Postgres/SQLite Joins are only allowed if the FROM clause is set as well.

pub fn replace_joins(
  query qry: Update(a),
  joins jns: List(Join),
) -> Update(a)

Replaces any Joins of the Update query with the given Joins.

NOTICE: On Postgres/SQLite Joins are only allowed if the FROM clause is set as well.

pub fn replace_where(
  query qry: Update(a),
  where whr: Where,
) -> Update(a)

Replaces the Where in the Update query.

pub fn returning(
  query qry: Update(a),
  returning rtrn: List(String),
) -> Update(a)

NOTICE: MariaDB/MySQL do not support RETURNING in UPDATE queries; they do support it in INSERT (and REPLACE) queries, however.

pub fn set(query qry: Update(a), set st: UpdateSet) -> Update(a)

Sets or appends one columne set in an Update query.

pub fn set_many_to_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 set_many_to_sub_query(
  columns cols: List(String),
  sub_query qry: Query,
) -> UpdateSet

Sets many columns to a sub-query value.

NOTICE: the sub-query must return an equal count of columns.

pub fn set_replace(
  query qry: Update(a),
  set st: UpdateSet,
) -> Update(a)

Sets or replaces one column set in an Update query.

pub fn set_to_expression(
  column col: String,
  expression exp: String,
) -> UpdateSet

Sets a column to an expression value.

pub fn set_to_param(
  column col: String,
  param prm: Param,
) -> UpdateSet

Sets a column to a param value.

pub fn set_to_sub_query(
  column col: String,
  sub_query qry: Query,
) -> UpdateSet

Sets a column to a sub-query value.

pub fn sets(
  query qry: Update(a),
  set sts: List(UpdateSet),
) -> Update(a)

Sets or appends many column sets n an Update query.

pub fn sets_replace(
  query qry: Update(a),
  sets sts: List(UpdateSet),
) -> Update(a)

Sets or replaces many column sets in an Update query.

pub fn string(value vl: String) -> Param

Creates a Param from a String.

pub fn table(
  query qry: 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(query qry: Update(a), where whr: Where) -> Update(a)

Sets an AndWhere or appends into an existing AndWhere.

  • If the outermost Where is an AndWhere, the new Where is appended to the list within AndWhere.
  • If the query does not have a Where clause, the given Where is set instead.
  • If the outermost Where is any other kind of Where, this and the current outermost Where are wrapped in an AndWhere.
pub fn xor_where(
  query qry: Update(a),
  where whr: Where,
) -> Update(a)

Sets an XorWhere or appends into an existing XorWhere.

  • If the outermost Where is an XorWhere, the new Where is appended to the list within XorWhere.
  • If the query does not have a Where clause, the given Where is set instead.
  • If the outermost Where is any other kind of Where, this and the current outermost Where are wrapped in an XorWhere.

NOTICE: This operator does not exist in Postgres or SQLite, and Cake generates equivalent SQL using OR and AND and NOT. This operator exists in MariaDB/MySQL.

Search Document