Skip to main content

join_using

Function join_using 

Source
pub fn join_using<'a, Table>(
    table: Table,
    columns: impl ToSQL<'a, PostgresValue<'a>>,
) -> SQL<'a, PostgresValue<'a>>
where Table: PostgresTable<'a>,
Expand description

Renders JOIN table USING (columns), which joins rows whose same-named columns are equal.

columns is rendered as given. PostgreSQL requires bare column names in USING, so pass identifiers such as SQL::ident("id"); a table column renders qualified ("posts"."id"), which the server rejects.

ยงExamples

use drizzle::core::SQL;
use drizzle::postgres::values::PostgresValue;

let join = drizzle::postgres::helpers::join_using(post, SQL::<PostgresValue>::ident("id"));
assert_eq!(join.sql(), r#"JOIN "posts" USING ("id")"#);