diesel::dsl

Type Alias InnerJoinQuerySource

Source
pub type InnerJoinQuerySource<Left, Right, On = <Left as JoinTo<Right>>::OnClause> = JoinOn<Join<Left, Right, Inner>, On>;
Expand description

A query source representing the inner join between two tables.

The third generic type (On) controls how the tables are joined.

By default, the implicit join established by joinable! will be used, allowing you to omit the exact join condition. For example, for the inner join between three tables that implement JoinTo, you only need to specify the tables: InnerJoinQuerySource<InnerJoinQuerySource<table1, table2>, table3>.

If you use an explicit ON clause, you will need to specify the On generic type.

use diesel::{dsl, helper_types::InnerJoinQuerySource};
use schema::*;

// If you have an explicit join like this...
let join_constraint = comments::columns::post_id.eq(posts::columns::id);
posts::table.inner_join(comments::table.on(join_constraint));

// ... you can use `InnerJoinQuerySource` like this.
type JoinConstraint = dsl::Eq<comments::columns::post_id, posts::columns::id>;
type MyInnerJoinQuerySource = InnerJoinQuerySource<posts::table, comments::table, JoinConstraint>;

Aliased Typeยง

struct InnerJoinQuerySource<Left, Right, On = <Left as JoinTo<Right>>::OnClause> { /* private fields */ }