pub struct Join {
pub join_type: JoinType,
pub table: String,
pub alias: Option<String>,
pub on: Expr,
pub lateral: bool,
pub is_subquery: bool,
pub subquery_params: Vec<Value>,
}Expand description
A JOIN clause.
Fields§
§join_type: JoinTypeType of join
table: StringTable to join (table name or subquery SQL)
alias: Option<String>Optional table alias
on: ExprON condition
lateral: boolWhether this is a LATERAL join (subquery can reference outer query columns).
Supported by PostgreSQL and MySQL 8.0+. Not supported by SQLite.
is_subquery: boolWhether the table field contains a subquery (wrapped in parentheses).
subquery_params: Vec<Value>Parameters from a subquery table expression.
Implementations§
Source§impl Join
impl Join
Sourcepub fn cross(table: impl Into<String>) -> Self
pub fn cross(table: impl Into<String>) -> Self
Create a CROSS JOIN (no ON condition needed, but we require one for uniformity).
Sourcepub fn lateral(
join_type: JoinType,
subquery_sql: impl Into<String>,
alias: impl Into<String>,
on: Expr,
params: Vec<Value>,
) -> Self
pub fn lateral( join_type: JoinType, subquery_sql: impl Into<String>, alias: impl Into<String>, on: Expr, params: Vec<Value>, ) -> Self
Create a LATERAL JOIN with a subquery.
A LATERAL subquery can reference columns from preceding FROM items. Supported by PostgreSQL (9.3+) and MySQL (8.0.14+). Not supported by SQLite.
§Arguments
join_type- The join type (typicallyJoinType::InnerorJoinType::Left)subquery_sql- The subquery SQL (without parentheses)alias- Required alias for the lateral subqueryon- ON condition (useExpr::raw("TRUE")for implicit join)params- Parameters for the subquery
Sourcepub fn left_lateral(
subquery_sql: impl Into<String>,
alias: impl Into<String>,
on: Expr,
params: Vec<Value>,
) -> Self
pub fn left_lateral( subquery_sql: impl Into<String>, alias: impl Into<String>, on: Expr, params: Vec<Value>, ) -> Self
Create a LEFT JOIN LATERAL (most common form).
Shorthand for Join::lateral(JoinType::Left, ...).
Sourcepub fn inner_lateral(
subquery_sql: impl Into<String>,
alias: impl Into<String>,
on: Expr,
params: Vec<Value>,
) -> Self
pub fn inner_lateral( subquery_sql: impl Into<String>, alias: impl Into<String>, on: Expr, params: Vec<Value>, ) -> Self
Create an INNER JOIN LATERAL.
Sourcepub fn cross_lateral(
subquery_sql: impl Into<String>,
alias: impl Into<String>,
params: Vec<Value>,
) -> Self
pub fn cross_lateral( subquery_sql: impl Into<String>, alias: impl Into<String>, params: Vec<Value>, ) -> Self
Create a CROSS JOIN LATERAL (no ON condition).
Sourcepub fn set_lateral(self) -> Self
pub fn set_lateral(self) -> Self
Mark this join as LATERAL.