Variable<T extends Object> class

An expression that represents the value of a dart object encoded to sql using prepared statements.

Inheritance
Available Extensions

Constructors

Variable(T? value)
Constructs a new variable from the value.
const

Properties

driftSqlType DriftSqlType<T>
The supported DriftSqlType backing this expression.
read-onlyinherited
hashCode int
The hash code for this object.
read-onlyoverride
isLiteral bool
Whether this expression is a literal. Some use-sites need to put parentheses around non-literals.
read-onlyinherited
precedence Precedence
The precedence of this expression. This can be used to automatically put parentheses around expressions as needed.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
value → T?
The Dart value that will be sent to the database
final

Methods

caseMatch<T extends Object>({required Map<Expression<T>, Expression<T>> when, Expression<T>? orElse}) Expression<T>
A CASE WHEN construct using the current expression as a base.
inherited
cast<D2 extends Object>() Expression<D2>
Generates a CAST(expression AS TYPE) expression.
inherited
dartCast<D2 extends Object>() Expression<D2>
Casts this expression to an expression of D.
inherited
equals(T 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 SQL-injection.
inherited
equalsExp(Expression<T> compare) Expression<bool>
Whether this expression is equal to the given expression.
inherited
equalsNullable(T? compare) Expression<bool>
Compares the value of this column to compare or null.
inherited
iif<T extends Object>(Expression<bool> predicate, Expression<T> ifFalse) Expression<T>
Evaluates to this if predicate is true, otherwise evaluates to ifFalse.
inherited
isExp(Expression<T> other) Expression<bool>
Generates an IS expression in SQL, comparing this expression with the other expression.
inherited
isIn(Iterable<T> values) Expression<bool>
An expression that is true if this resolves to any of the values in values.
inherited
isInQuery(BaseSelectStatement select) Expression<bool>
An expression checking whether this is included in any row of the provided select statement.
inherited
isNotExp(Expression<T> other) Expression<bool>
Generates an IS NOT expression in SQL, comparing this expression with the other expression.
inherited
isNotIn(Iterable<T> values) Expression<bool>
An expression that is true if this does not resolve to any of the values in values.
inherited
isNotInQuery(BaseSelectStatement select) Expression<bool>
An expression checking whether this is not included in any row of the provided select statement.
inherited
isNotNull() Expression<bool>
Expression that is true if the inner expression resolves to a non-null value.
inherited
isNotValue(T value) Expression<bool>
Generates an IS NOT expression in SQL, comparing this expression with the Dart value.
inherited
isNull() Expression<bool>
Expression that is true if the inner expression resolves to a null value.
inherited
isValue(T value) Expression<bool>
Generates an IS expression in SQL, comparing this expression with the Dart value.
inherited
mapToSimpleValue(GenerationContext context) → dynamic
Maps value to something that should be understood by the underlying database engine. For instance, a DateTime will me mapped to its unix timestamp.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
nullIf(Expression<T> matcher) Expression<T>
Returns null if matcher is equal to this expression, this otherwise.
inherited
toString() String
A string representation of this object.
override
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 of this expression is lower, it will be wrap}ped in
inherited
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.
inherited
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.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

withBigInt(BigInt value) Variable<BigInt>
Creates a variable that holds the specified BigInt.
withBlob(Uint8List value) Variable<Uint8List>
Creates a variable that holds the specified data blob.
withBool(bool value) Variable<bool>
Creates a variable that holds the specified boolean.
withDateTime(DateTime value) Variable<DateTime>
Creates a variable that holds the specified date.
withInt(int value) Variable<int>
Creates a variable that holds the specified int.
withReal(double value) Variable<double>
Creates a variable that holds the specified floating point value.
withString(String value) Variable<String>
Creates a variable that holds the specified string.