Skip to main content

Join

Struct Join 

Source
pub struct Join {
    pub kind: JoinKind,
    pub to: TableRef,
    pub natural: bool,
    pub on: Vec<Expr>,
    pub using: Vec<Cow<'static, str>>,
    pub using_alias: Option<Cow<'static, str>>,
}
Expand description

[NATURAL] <kind> <table> [ON a AND b] [USING (cols) [AS alias]]

From PostgreSQL 17’s from_item:

from_item [ NATURAL ] join_type from_item
    [ ON join_condition | USING ( join_column [, ...] ) [ AS join_using_alias ] ]

ON and USING are alternatives, and NATURAL excludes both; nothing here enforces that, because the check belongs to the mods that build a join — a dialect exposes join::on(..) and join::using(..) as separate mods and the caller picks one.

Fields§

§kind: JoinKind

Which join.

§to: TableRef

What is being joined to, with all of its own decorations.

§natural: bool

NATURAL, which derives the join columns from the two items’ names.

§on: Vec<Expr>

ON conditions, AND-joined.

§using: Vec<Cow<'static, str>>

USING columns, quoted on output.

§using_alias: Option<Cow<'static, str>>

USING (…) AS alias — a name for the row of merged join columns (PostgreSQL 16+). Quoted on output. Belongs to the USING clause, so with no using columns it is a recorded build error rather than something to guess a rendering for.

Implementations§

Source§

impl Join

Source

pub fn new(kind: JoinKind, to: TableRef) -> Self

A join of kind onto to, with no condition yet.

Source

pub fn append_on(&mut self, condition: impl IntoExpr)

Append an ON condition.

Source

pub fn append_using( &mut self, columns: impl IntoIterator<Item = impl Into<Cow<'static, str>>>, )

Append USING columns.

Source

pub fn is_empty(&self) -> bool

Whether there is nothing to join to, so that nothing will be written.

Trait Implementations§

Source§

impl Clone for Join

Source§

fn clone(&self) -> Join

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Join

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Join

Source§

fn default() -> Join

Returns the “default value” for a type. Read more
Source§

impl Expression for Join

Source§

fn write_sql(&self, w: &mut SqlWriter<'_>)

Append this fragment to w. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Join

§

impl !UnwindSafe for Join

§

impl Freeze for Join

§

impl Send for Join

§

impl Sync for Join

§

impl Unpin for Join

§

impl UnsafeUnpin for Join

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.