cake/where

Used to build WHERE clauses for SQL queries.

Where clauses are used to filter rows in a table.

Also used to build HAVING clauses for SQL queries, because they work the same way as WHERE clauses, but are used to filter rows after GROUP BY has been applied.

Compatibility

Types

pub type Fragment =
  @internal Fragment
pub type ReadQuery =
  @internal ReadQuery
pub type Where =
  @internal Where
pub type WhereValue =
  @internal WhereValue

Values

pub fn and(wheres whrs: List(@internal Where)) -> @internal Where

Logical AND of multiple Wheres.

pub fn between(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
  value_c vl_c: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue A is between two WhereValues B and C.

pub fn col(name: String) -> @internal WhereValue

Creates a WhereValue from a column name String.

pub fn eq(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue equals another WhereValue.

pub fn eq_all_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue matches all in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn eq_any_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue matches any in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn exists_in_query(
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if it exists in a sub-query.

pub fn false() -> @internal WhereValue

Creates a FALSE WhereValue.

Notice: You probably want to use where.is_false() instead.

pub fn float(v vl: Float) -> @internal WhereValue

Creates a WhereValue from a Float.

pub fn fragment(
  fragment frgmt: @internal Fragment,
) -> @internal Where

Creates a WhereFragment from a Fragment.

pub fn fragment_value(
  fragment frgmt: @internal Fragment,
) -> @internal WhereValue

Creates a WhereValue from a Fragment.

pub fn gt(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater than another WhereValue.

pub fn gt_all_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater than all in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn gt_any_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater than any in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn gte(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater or equal to another WhereValue.

pub fn gte_all_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater or equal to all in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn gte_any_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is greater or equal to any in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn ilike(
  value vl: @internal WhereValue,
  pattern pttrn: String,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue matches a pattern.

ilike is the same as like but case-insensitive.

pub fn in(
  value vl: @internal WhereValue,
  values vals: List(@internal WhereValue),
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is in a list of WhereValues.

pub fn in_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is IN a sub-query.

NOTICE: Usually the sub-query must return a single column.

pub fn int(v vl: Int) -> @internal WhereValue

Creates a WhereValue from an Int.

pub fn is_bool(
  value vl: @internal WhereValue,
  bool b: Bool,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue matches a Bool.

pub fn is_false(
  value vl: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is False.

pub fn is_not_bool(
  value vl: @internal WhereValue,
  bool b: Bool,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue does not match a Bool.

pub fn is_not_null(
  value vl: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is not SQL NULL.

pub fn is_null(value vl: @internal WhereValue) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is SQL NULL.

pub fn is_true(value vl: @internal WhereValue) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is True.

pub fn like(
  value vl: @internal WhereValue,
  pattern pttrn: String,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue matches a pattern. The pattern can contain for example the following wildcards:

  • % matches any sequence of characters.
  • _ matches any single character.
pub fn lt(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue lower than another WhereValue.

pub fn lt_all_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is lower than all in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn lt_any_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is lower than an any in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn lte(
  value_a vl_a: @internal WhereValue,
  value_b vl_b: @internal WhereValue,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue lower or equal to another WhereValue.

pub fn lte_all_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is lower or equal to all in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn lte_any_query(
  value vl: @internal WhereValue,
  sub_query qry: @internal ReadQuery,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is lower or equal to any in a sub-query.

NOTICE: Not supported by 🪶SQLite.

pub fn none() -> @internal Where

No where condition.

pub fn not(where whr: @internal Where) -> @internal Where

Negates a Where.

pub fn null() -> @internal WhereValue

Creates a NULL WhereValue.

pub fn or(wheres whrs: List(@internal Where)) -> @internal Where

Logical OR of multiple Wheres.

pub fn similar_to(
  value vl: @internal WhereValue,
  to pttrn: String,
  escape_with escp_char: String,
) -> @internal Where

Creates a WHERE clause that checks if a WhereValue is similar to a pattern.

NOTICE: Not supported by 🪶SQLite.

pub fn string(v vl: String) -> @internal WhereValue

Creates a WhereValue from a String.

pub fn sub_query(
  query qry: @internal ReadQuery,
) -> @internal WhereValue

Creates a WhereValue off a ReadQuery.

NOTICE: Usually the sub-query must return a single column.

pub fn true() -> @internal WhereValue

Creates a TRUE WhereValue.

Notice: You probably want to use where.is_true() instead.

pub fn xor(wheres whrs: List(@internal Where)) -> @internal Where

Logical XOR of multiple Wheres.

Search Document