Module diesel::expression [] [src]

AST types representing various typed SQL expressions. Almost all types implement either Expression or AsExpression.

The most common expression to work with is a Column. There are various methods that you can call on these, found in expression_methods. You can also call numeric operators on types which have been passed to operator_allowed! or numeric_expr!.

Any primitive which implements ToSql will also implement AsExpression, allowing it to be used as an argument to any of the methods described here.



The types in this module are all shorthand for PredicateType<Lhs, AsExpr<Rhs, Lhs>>. Since we often need to return concrete types, instead of a boxed trait object, these can be useful for writing concise return types.



Available for when you truly cannot represent something using the expression DSL. You will need to provide the type of the expression, in addition to the SQL. The compiler will be unable to verify the correctness of this type.



Indicates that all elements of an expression are valid given a from clause. This is used to ensure that users.filter(posts::id.eq(1)) fails to compile. This constraint is only used in places where the nullability of a SQL type doesn't matter (everything except select and returning). For places where nullability is important, SelectableExpression is used instead.


Converts a type to its representation for use in Diesel's query builder.


Helper trait used when boxing expressions. This exists to work around the fact that Rust will not let us use non-core types as bounds on a trait object (you could not return Box<Expression+NonAggregate>)


Represents a typed fragment of SQL.


Converts a type to its representation for use in Diesel's query builder.


Marker trait to indicate that an expression does not include any aggregate functions. Used to ensure that aggregate expressions aren't mixed with non-aggregate expressions in a select clause, and that they're never included in a where clause.


Indicates that an expression can be selected from a source. Columns will implement this for their table. Certain special types, like CountStar and Bound will implement this for all sources. Most compound expressions will implement this if each of their parts implement it.