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 = UsersTableRequired Associated Types§
Sourcetype Table: TypedTable
type Table: TypedTable
表达式所属的表
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".