Expand description
Typed expression AST (Django Q / F / lookup equivalents).
Expressions are pure data: building them never performs I/O. Backends compile them into their own dialect.
Two layers exist:
Expr: untyped tree stored inside aQueryPlan.Field<M, T>: a typed column handle. TheModelderive generates one associated constant per field (User::name), so lookups are checked at compile time:icontainsexists only on text fields, comparison values must convert into the field’s type.Calc(arithmetic results) andJoined(fields reached through a foreign key) offer the same lookups.
Function, aggregate and window constructors live in functions,
Count/Sum/… and RowNumber/Rank/….
Re-exports§
pub use functions::CaseBuilder;pub use functions::DatePart;pub use functions::Function;
Modules§
- functions
- Scalar functions,
CASEand date-part extraction.
Structs§
- Aggregate
- An aggregate call: function, argument,
DISTINCTandFILTER (WHERE ..). - Array
Agg - Collect values into an array (PostgreSQL only).
- Avg
AVG(expr).- Calc
- Result of arithmetic on typed handles: an expression that is still known
to have type
T, so it can be compared with and assigned toTfields. - Column
- A (optionally source-qualified) column reference.
- Count
COUNT(*)andCOUNT(expr).- Cume
Dist CUME_DIST().- Dense
Rank DENSE_RANK().- Field
- Typed column handle for model
Mwhose Rust type isT. - First
Value FIRST_VALUE(expr).- Joined
- A column of a related model, usable like a field of the root model
M. - Lag
LAG(expr, offset).- Last
Value LAST_VALUE(expr).- Lead
LEAD(expr, offset).- Max
MAX(expr).- Min
MIN(expr).- Ntile
NTILE(n).- Percent
Rank PERCENT_RANK().- Rank
RANK().- RelHop
- One foreign-key hop:
<parent>.<fk_column> = <table>.<pk_column>. - Related
Column - A column of a related model, addressed by its foreign-key path.
- RowNumber
ROW_NUMBER().- StdDev
- Standard deviation (PostgreSQL only).
- String
Agg - Join text values with a separator (
STRING_AGGon PostgreSQL,group_concaton SQLite). - Sum
SUM(expr).NULLfor an empty group; PostgreSQL returnsnumericfor integer sums.- Variance
- Variance (PostgreSQL only).
- Window
- A window function with its
PARTITION BYandORDER BY.
Enums§
- AggFunc
- The aggregate function computed.
- Binary
Op - Binary operators: comparisons, boolean connectives and arithmetic.
- Expr
- Expression tree node.
- Lookup
- Lookups that are not plain binary comparisons.
- UnaryOp
- Unary operators.
- Window
Func - The function evaluated over the window.
Traits§
- Date
Like - Column types that have a calendar date (
year,month, …). - FkSlot
- A foreign-key slot of a model struct:
ForeignKey<T>orOption<ForeignKey<T>>. - Literal
- A literal value that can stand for a
Tcolumn (no column references), used byis_inandrange. - Numeric
- Column types that support arithmetic.
- Operand
- A value that can stand for a
Tcolumn in a comparison or assignment: aT, aTfor anOption<T>column, a primary key or model reference for a foreign key, or another typed handle of typeT. - Related
- Column of related model
Tthat can be reached through more hops: aFieldofT, or aJoinedhandle already rooted atT. - Text
Like - Text column types (
icontains,starts_with, …). - Time
Like - Column types that have a time of day (
hour,minute,second).
Functions§
- path_
alias_ of - Alias of the table reached by
path.
Type Aliases§
- Ident
- Identifier type used for tables, aliases and columns.