pub struct Expr { /* private fields */ }
Expand description
An expression on database rows that can be used in queries.
Implementations§
source§impl Expr
impl Expr
sourcepub fn col<S: Into<String>>(column_name: S) -> Expr
pub fn col<S: Into<String>>(column_name: S) -> Expr
Returns an expression that evaluates to the value of the specified column.
sourcepub fn boolean(boolean: bool) -> Expr
pub fn boolean(boolean: bool) -> Expr
Returns an expression that evaluates to the given boolean value.
sourcepub fn integer(integer: i32) -> Expr
pub fn integer(integer: i32) -> Expr
Returns an expression that evaluates to the given integer value.
sourcepub fn string<S: Into<String>>(string: S) -> Expr
pub fn string<S: Into<String>>(string: S) -> Expr
Returns an expression that evaluates to the given string value.
sourcepub fn eq(self, rhs: Expr) -> Expr
pub fn eq(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the two subexpressions evaluate to equal values.
sourcepub fn ne(self, rhs: Expr) -> Expr
pub fn ne(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the two subexpressions evaluate to unequal values.
sourcepub fn lt(self, rhs: Expr) -> Expr
pub fn lt(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the left-hand subexpression evaluates to a strictly lesser value than the right-hand subexpression.
sourcepub fn le(self, rhs: Expr) -> Expr
pub fn le(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the left-hand subexpression evaluates to a lesser-or-equal value than the right-hand subexpression.
sourcepub fn gt(self, rhs: Expr) -> Expr
pub fn gt(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the left-hand subexpression evaluates to a strictly greater value than the right-hand subexpression.
sourcepub fn ge(self, rhs: Expr) -> Expr
pub fn ge(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if the left-hand subexpression evaluates to a greater-or-equal value than the right-hand subexpression.
sourcepub fn bitinv(self) -> Expr
pub fn bitinv(self) -> Expr
Returns an expression that computes the bitwise inverse of the subexpression. If the subexpression evaluates to a non-number, the result will be a null value.
This method exists instead of the std::ops::Not
trait to distinguish
it from the (logical) not()
method.
sourcepub fn and(self, rhs: Expr) -> Expr
pub fn and(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if both subexpressions evaluate to true.
sourcepub fn or(self, rhs: Expr) -> Expr
pub fn or(self, rhs: Expr) -> Expr
Returns an expression that evaluates to true if either subexpression evaluates to true.
sourcepub fn not(self) -> Expr
pub fn not(self) -> Expr
Returns an expression that evaluates to true if the subexpression evaluates to false.
This method exists instead of the std::ops::Not
trait to distinguish
it from the (bitwise) bitinv()
method.
sourcepub fn eval(&self, row: &Row) -> Value
pub fn eval(&self, row: &Row) -> Value
Evaluates the expression against the given row. Any errors in the expression (such as dividing a number by zero, or applying a bitwise operator to a string) will result in a null value.
sourcepub fn column_names(&self) -> HashSet<&str>
pub fn column_names(&self) -> HashSet<&str>
Returns the set of all column names referenced by this expression.
Trait Implementations§
source§impl Add for Expr
impl Add for Expr
Produces an expression that evaluates to the sum of the two subexpressions (if they are integers) or concatenation (if they are strings). If the two subexpressions evaluate to different types, or if either evaluates to a null value, the result will be a null value.
source§impl BitAnd for Expr
impl BitAnd for Expr
Produces an expression that evaluates to the bitwise-and of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.
source§impl BitOr for Expr
impl BitOr for Expr
Produces an expression that evaluates to the bitwise-or of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.
source§impl BitXor for Expr
impl BitXor for Expr
Produces an expression that evaluates to the bitwise-xor of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.
source§impl Div for Expr
impl Div for Expr
Produces an expression that evaluates to the integer quotient of the two subexpressions. If either subexpression evaluates to a non-number, or if the divisor evalulates to zero, the result will be a null value.
source§impl Mul for Expr
impl Mul for Expr
Produces an expression that evaluates to the product of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.
source§impl Neg for Expr
impl Neg for Expr
Produces an expression that evaluates to the negative of the subexpression. If the subexpression evaluates to a non-number, the result will be a null value.
source§impl Shl for Expr
impl Shl for Expr
Produces an expression that evaluates to the value of the left-hand subexpression bit-shifted left by the value of the right-hand subexpression. If either subexpression evaluates to a non-number, the result will be a null value.
source§impl Shr for Expr
impl Shr for Expr
Produces an expression that evaluates to the value of the left-hand subexpression bit-shifted right by the value of the right-hand subexpression. If either subexpression evaluates to a non-number, the result will be a null value.