Expression<D extends Object> class
abstract
Any sql expression that evaluates to some generic value. This does not include queries (which might evaluate to multiple values) but individual columns, functions and operators.
To obtain the result of an Expression, add it as a result column to a JoinedSelectStatement, e.g. through DatabaseConnectionUser.selectOnly:
Expression<int> countUsers = users.id.count();
// Add the expression to a select statement to evaluate it.
final query = selectOnly(users)..addColumns([countUsers]);
final row = await query.getSingle();
// Use .read() on a row to read expressions.
final amountOfUsers = query.read(counUsers);
It's important that all subclasses properly implement hashCode and ==.
 Implemented types
 Implementers
 Available Extensions
Constructors
 Expression()

Constant constructor so that subclasses can be constant.
const
Properties

driftSqlType
→ BaseSqlType<
D> 
The
BaseSqlType
backing this expression.no setter  hashCode → int

The hash code for this object.
no setterinherited
 isLiteral → bool

Whether this expression is a literal. Some usesites need to put
parentheses around nonliterals.
no setter
 precedence → Precedence

The precedence of this expression. This can be used to automatically put
parentheses around expressions as needed.
no setter
 runtimeType → Type

A representation of the runtime type of the object.
no setterinherited
Methods

caseMatch<
T extends Object> ({required Map< Expression< when, Expression<D> , Expression<T> >T> ? orElse}) → Expression<T> 
A
CASE WHEN
construct using the current expression as a base. 
cast<
D2 extends Object> ([BaseSqlType< D2> ? type]) → Expression<D2> 
Generates a
CAST(expression AS TYPE)
expression. 
dartCast<
D2 extends Object> ({CustomSqlType< D2> ? customType}) → Expression<D2> 
Casts this expression to an expression of
D
. 
equals(
D compare) → Expression< bool> 
Whether this column is equal to the given value, which must have a fitting
type. The
compare
value will be written as a variable using prepared statements, so there is no risk of an SQLinjection. 
equalsExp(
Expression< D> compare) → Expression<bool>  Whether this expression is equal to the given expression.

equalsNullable(
D? compare) → Expression< bool> 
Compares the value of this column to
compare
ornull
. 
iif<
T extends Object> (Expression< bool> predicate, Expression<T> ifFalse) → Expression<T> 
Evaluates to
this
ifpredicate
is true, otherwise evaluates toifFalse
. 
isExp(
Expression< D> other) → Expression<bool> 
Generates an
IS
expression in SQL, comparing this expression with theother
expression. 
isIn(
Iterable< D> values) → Expression<bool> 
An expression that is true if
this
resolves to any of the values invalues
. 
isInExp(
List< Expression< expressions) → Expression<D> >bool> 
An expression that evaluates to
true
if this expression resolves to a value that one of theexpressions
resolve to as well. 
isInQuery(
BaseSelectStatement select) → Expression< bool> 
An expression checking whether
this
is included in any row of the providedselect
statement. 
isNotExp(
Expression< D> other) → Expression<bool> 
Generates an
IS NOT
expression in SQL, comparing this expression with theother
expression. 
isNotIn(
Iterable< D> values) → Expression<bool> 
An expression that is true if
this
does not resolve to any of the values invalues
. 
isNotInExp(
List< Expression< expressions) → Expression<D> >bool> 
An expression that evaluates to
true
if this expression does not resolve to any value that theexpressions
resolve to. 
isNotInQuery(
BaseSelectStatement select) → Expression< bool> 
An expression checking whether
this
is not included in any row of the providedselect
statement. 
isNotNull(
) → Expression< bool>  Expression that is true if the inner expression resolves to a nonnull value.

isNotValue(
D value) → Expression< bool> 
Generates an
IS NOT
expression in SQL, comparing this expression with the Dartvalue
. 
isNull(
) → Expression< bool>  Expression that is true if the inner expression resolves to a null value.

isValue(
D value) → Expression< bool> 
Generates an
IS
expression in SQL, comparing this expression with the Dartvalue
. 
noSuchMethod(
Invocation invocation) → dynamic 
Invoked when a nonexistent method or property is accessed.
inherited

nullIf(
Expression< D> matcher) → Expression<D> 
Returns
null
ifmatcher
is equal to this expression,this
otherwise. 
toString(
) → String 
A string representation of this object.
inherited

writeAroundPrecedence(
GenerationContext context, Precedence precedence) → void 
Writes this expression into the GenerationContext, assuming that there's
an outer expression with
precedence
. If the Expression.precedence ofthis
expression is lower, it will be wrap}ped in 
writeInner(
GenerationContext ctx, Expression< Object> inner) → void 
If this Expression wraps an
inner
expression, this utility method can be used inside writeInto to write that inner expression while wrapping it in parentheses if necessary. 
writeInto(
GenerationContext context) → void 
Writes this component into the
context
by writing to its GenerationContext.buffer or by introducing bound variables. When writing into the buffer, no whitespace around the this component should be introduced. When a component consists of multiple composed component, it's responsible for introducing whitespace between its child components.inherited
Operators

operator ==(
Object other) → bool 
The equality operator.
inherited
Static Methods

and(
Iterable< Expression< predicates, {Expression<bool> >bool> ifEmpty = const Constant(true)}) → Expression<bool> 
Chains all
predicates
together into a single expression that will evaluate totrue
iff all of thepredicates
evaluates totrue
. 
or(
Iterable< Expression< predicates, {Expression<bool> >bool> ifEmpty = const Constant(false)}) → Expression<bool> 
Chains all
predicates
together into a single expression that will evaluate totrue
iff any of thepredicates
evaluates totrue
.