Skip to main content

Module shared

Module shared 

Source
Expand description

The mods, written once against the Has* traits and re-exported per statement.

Nothing in here names a query type. A mod is Mod<Q> for every Q that implements the clause trait it needs, so where_ is one function that serves SELECT, UPDATE, DELETE and the DO UPDATE body of an upsert — and refuses to compile against an INSERT, which has no WHERE.

Three shapes recur.

A plain mod is a function returning impl Mod<Q>, built from mod_fn.

A chain is a struct that is itself a mod and has builder methods. It exists wherever a clause has decorations that must be set together rather than one mod at a time: from(..).as_("u").not_indexed() replaces the whole from-item once, so no later mod can silently wipe an earlier one.

A slot is how one chain type reaches different fields of different queries. select::from and update::table are the same chain with a different TableSlot; the marker is a type parameter, so which field is written is decided at compile time and there is one implementation of the builder methods.

Structs§

ConflictChain
An upsert-clause under construction.
ConflictMod
A finished upsert-clause, ready to apply.
CteChain
A common table expression under construction.
ExtraSlot
The additional-from-items slot, for the second and later entries of a comma-separated FROM list.
FromSlot
The from-item slot: a SELECT’s or an UPDATE’s FROM.
IntoChain
An INSERT’s target under construction: INTO "t" AS "alias" ("a", "b").
JoinChain
A join under construction.
OrderChain
One ordering-term under construction.
SetChain
The left-hand side of an assignment: set_col("a").to(arg(1)).
TableChain
A table-or-subquery — or a qualified-table-name — under construction.
TargetSlot
The target slot: the table an UPDATE writes to or a DELETE removes from.

Traits§

TableSlot
Where a TableChain puts the table reference it has built.

Functions§

columns
Add to the result columns. Several calls accumulate; with none, * is written.
cross_join
CROSS JOIN <table> — an inner join that also pins the join order.
except
EXCEPT <select-core> — rows of this query that are not in the other. There is no EXCEPT ALL.
extra_from_item
A further comma-separated from-item. A comma is one of SQLite’s join-operators and means the same as CROSS JOIN.
from_item
A from-item: FROM <table>.
full_join
FULL JOIN <table> — SQLite 3.39 and later.
group_by
Add a grouping expression.
having
HAVING condition. Several calls are AND-joined.
inner_join
INNER JOIN <table>.
intersect
INTERSECT <select-core> — rows of both. There is no INTERSECT ALL.
into_table
INSERT INTO <table>.
left_join
LEFT JOIN <table>.
limit
LIMIT count.
offset
OFFSET start.
on_conflict
ON CONFLICT (columns) — infer the unique index from a column list.
or_abort
OR ABORT — abort this statement and undo it, but keep the transaction. The default, written out.
or_fail
OR FAIL — stop at the offending row, keeping the changes made before it.
or_ignore
OR IGNORE — skip the offending row and carry on with the rest.
or_replace
OR REPLACE — delete the rows that conflict, then proceed. This is what SQLite’s REPLACE INTO is short for.
or_rollback
OR ROLLBACK — a constraint violation aborts the whole transaction.
order_by
ORDER BY expression.
preload_columns
Add to the preload result columns, which render after columns but are counted separately.
recursive
WITH RECURSIVE rather than WITH.
returning
RETURNING a, b. returning("*") is an ordinary entry.
right_join
RIGHT JOIN <table> — SQLite 3.39 and later.
rows
Several rows of VALUES at once.
set
One assignment, written out: set(quote("a").eq(arg(1))).
set_col
Assign to a column. set_col(("t", "a")) qualifies it, which UPDATE forbids but an upsert’s DO UPDATE permits.
set_excluded
"col" = excluded."col" for each column — the body of an upsert.
target_table
The statement’s target table: what an UPDATE writes to, what a DELETE removes from.
union
UNION <select-core> — rows of either, duplicates removed.
union_all
UNION ALL <select-core> — rows of either, duplicates kept.
values
One row of VALUES. Several calls append several rows.
values_from_query
Insert the results of a query: INSERT INTO t (cols) SELECT ….
where_
WHERE condition. Several calls are AND-joined; use or for the other connective.
window
WINDOW "name" AS (definition), the definition built from window and frame mods.
with
WITH "name" AS (body).