Tables and expressions
orm_table! is the entry point to the query type system. It creates a zero-sized marker that implements Table and a constructor returning Column<Table, Value> for every column.
Declare a table
Table and column names must be valid SQL identifiers. The compiler quotes them for the selected dialect. Application values never use this identifier path.
Column ownership
The table marker is part of every column type. This assignment fails during Rust compilation because Pet::name() is not owned by Person:
The same rule protects inserts, conflict updates, lock targets, and typed joins.
Value comparisons and nulls
Columns provide value comparisons, column comparisons, and null predicates:
Nullable and non-nullable columns can be compared when their base value families are compatible. is_null and is_not_null always emit SQL null predicates instead of binding NULL with =.
Boolean composition
and, or, and not retain an explicit expression tree. The compiler adds parentheses to preserve semantics.
Typed functions
sql_function validates function names and cast validates target type names. Their Rust result types are explicit caller assertions. The library does not query database metadata to infer them.
Selection aliases
Aliases use the same validation and quoting rules as table identifiers.
Table aliases
Self joins use a separate table marker:
The AST stores the source and alias separately. Columns must come from the alias marker, which prevents invalid SQL with original-table qualifiers.