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.

Reexports

pub use self::dsl::*;
pub use self::sql_literal::SqlLiteral;

Modules

dsl

Reexports various top level functions and core extensions that are too generic to export by default. This module exists to conveniently glob import in functions where you need them.

expression_methods

Adds various methods to construct new expressions. These traits are exported by default, and implemented automatically.

helper_types

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.

sql_literal

Traits

AsExpression

Describes how a type can be represented as an expression for a given type. These types couldn't just implement Expression directly, as many things can be used as an expression of multiple types. (String for example, can be used as either VarChar or Text).

BoxableExpression

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>)

Expression

Represents a typed fragment of SQL. Apps should not need to implement this type directly, but it may be common to use this as type boundaries. Libraries should consider using infix_predicate! or postfix_predicate! instead of implementing this directly.

NonAggregate

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.

SelectableExpression

Indicates that an expression can be selected from a source. The second type argument is optional, but is used to indicate that the right side of a left outer join is nullable, even if it wasn't before.