pub struct TableRef {
pub expression: Option<Expr>,
pub alias: Option<Cow<'static, str>>,
pub columns: Vec<Cow<'static, str>>,
pub only: bool,
pub lateral: bool,
pub with_ordinality: bool,
pub partitions: Vec<Cow<'static, str>>,
pub index_hints: Vec<IndexHint>,
pub indexed_by: Option<IndexedBy>,
pub joins: Vec<Join>,
}Expand description
A from_item: a table, a sub-select, a function call or a CTE name, plus every
decoration the three dialects hang off one, plus its joins.
[ONLY] [LATERAL] expr [WITH ORDINALITY] [PARTITION (…)] [[AS] alias [(cols)]]
[index hints] [INDEXED BY … | NOT INDEXED] [joins]The order is PostgreSQL’s from_item production
(https://www.postgresql.org/docs/17/sql-select.html) with MySQL’s
table_reference (https://dev.mysql.com/doc/refman/8.4/en/join.html) and
SQLite’s qualified-table-name slotted into the positions those grammars put
them in.
Every dialect’s decorations live on this one struct rather than in three
near-identical copies, because a shared Join has to be able to hold a
TableRef whatever dialect it came from. Which of them a dialect permits is
decided by which mods that dialect exports — not by this shape. The
dialect-specific fields are labelled below.
The same struct is also an INSERT’s target, where
columns is the insert column list, and an UPDATE’s or
DELETE’s table.
Fields§
§expression: Option<Expr>The table, sub-select, function call or CTE name.
alias: Option<Cow<'static, str>>The table alias, quoted on output.
columns: Vec<Cow<'static, str>>Column aliases — or, for an INSERT, the insert column list. Quoted.
only: boolPostgreSQL ONLY: do not include descendant tables.
lateral: boolPostgreSQL and MySQL LATERAL.
with_ordinality: boolPostgreSQL WITH ORDINALITY, for a set-returning function.
partitions: Vec<Cow<'static, str>>MySQL PARTITION (…). Quoted.
index_hints: Vec<IndexHint>MySQL USE/FORCE/IGNORE INDEX.
indexed_by: Option<IndexedBy>SQLite INDEXED BY … / NOT INDEXED.
joins: Vec<Join>Joins hanging off this item, rendered after all of its decorations.
Implementations§
Source§impl TableRef
impl TableRef
Sourcepub fn set_alias(&mut self, alias: impl Into<Cow<'static, str>>)
pub fn set_alias(&mut self, alias: impl Into<Cow<'static, str>>)
Set the alias. Column aliases are set_columns, so
that neither has to be named to set the other.
Sourcepub fn set_columns(
&mut self,
columns: impl IntoIterator<Item = impl Into<Cow<'static, str>>>,
)
pub fn set_columns( &mut self, columns: impl IntoIterator<Item = impl Into<Cow<'static, str>>>, )
Set the column aliases — or, for an INSERT, the insert column list.
Sourcepub fn append_join(&mut self, join: Join)
pub fn append_join(&mut self, join: Join)
Append a join.
Sourcepub fn append_partition(
&mut self,
names: impl IntoIterator<Item = impl Into<Cow<'static, str>>>,
)
pub fn append_partition( &mut self, names: impl IntoIterator<Item = impl Into<Cow<'static, str>>>, )
Append MySQL partition names.
Sourcepub fn append_index_hint(&mut self, hint: IndexHint)
pub fn append_index_hint(&mut self, hint: IndexHint)
Append a MySQL index hint.