Skip to main content

ExprTable

Trait ExprTable 

Source
pub trait ExprTable {
    type Table: TypedTable;
}
Expand description

表达式所属的表(用于跨表列引用检查)

该 trait 将表达式与其所属的表关联,使 TypedSelectQuery::filter 能在编译期 拒绝引用了其他表的列的表达式。

  • 列引用/比较表达式:表由列的 TypedColumn::Table 决定
  • 逻辑组合表达式(And/Or):两侧子表达式必须属于同一张表

§跨表拒绝示例

// 假设 ColPostTitle 属于 PostsTable,而查询是 TypedSelectQuery::<UsersTable>
// 以下代码无法编译:
TypedSelectQuery::<UsersTable>::new()
    .filter(ColPostTitle.eq("hello"));  // ❌ ExprTable<Table = PostsTable> 不满足 Table = UsersTable

Required Associated Types§

Source

type Table: TypedTable

表达式所属的表

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C, V> ExprTable for Eq<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C, V> ExprTable for Ge<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C, V> ExprTable for Gt<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C, V> ExprTable for Le<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C, V> ExprTable for Lt<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C, V> ExprTable for Ne<C, V>
where C: TypedColumn, V: Clone,

Source§

impl<C> ExprTable for ColumnExpr<C>
where C: TypedColumn,

Source§

impl<L, R> ExprTable for And<L, R>
where L: ExprTable + TypedExpression<SqlType = Bool>, R: TypedExpression<SqlType = Bool> + ExprTable<Table = <L as ExprTable>::Table>,

Source§

impl<L, R> ExprTable for Or<L, R>
where L: ExprTable + TypedExpression<SqlType = Bool>, R: TypedExpression<SqlType = Bool> + ExprTable<Table = <L as ExprTable>::Table>,