CaseWhenExpression<R extends Object> class

A CASE WHEN expression without a base expression in sqlite.

This expression evaluates to the first value in BaseCaseWhenExpression.orderedCases for which CaseWhen.when evaluates to true.

Inheritance
Available extensions

Constructors

CaseWhenExpression({required List<CaseWhen<bool, R>> cases, Expression<R>? orElse})
Creates a CASE WHEN expression from the independent components.

Properties

base Expression<bool>?
The optional base expression.
finalinherited
date Expression<String>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime in the format year-month-day.
no setter
datetime Expression<String>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime in the format year-month-day hour:minute:second.
no setter
day Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the day from this datetime expression.
no setter
driftSqlType → BaseSqlType<R>
The BaseSqlType backing this expression.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hour Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the hour from this datetime expression.
no setter
isLiteral bool
Whether this expression is a literal. Some use-sites need to put parentheses around non-literals.
no setterinherited
julianday Expression<double>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime in the Julian day format - a fractional number of days since noon in Greenwich on November 24, 4714 B.C.
no setter
length Expression<int>

Available on Expression<String>, provided by the StringExpressionOperators extension

Calls the sqlite function LENGTH on this string, which counts the number of characters in this string. Note that, in most sqlite installations, length may not support all unicode rules.
no setter
minute Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the minute from this datetime expression.
no setter
month Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the month from this datetime expression.
no setter
orderedCases Iterable<CaseWhen<bool, R>>
The when-then entries for this expression.
finalinherited
orElse Expression<R>?
The expression to use if no entry in orderedCases matched.
finalinherited
precedence Precedence
The precedence of this expression. This can be used to automatically put parentheses around expressions as needed.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
second Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the second from this datetime expression.
no setter
secondsSinceEpoch Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Returns an expression containing the amount of seconds from the unix epoch (January 1st, 1970) to this datetime expression.
no setter
time Expression<String>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime in the format hour:minute:second.
no setter
unixepoch Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime as a unix timestamp - the number of seconds since 1970-01-01 00:00:00 UTC.
no setter
year Expression<int>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Extracts the year from this datetime expression.
no setter

Methods

abs() Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Calculates the absolute value of this number.
abs() Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Calculates the absolute value of this number.
avg({Expression<bool>? filter}) Expression<double>

Available on Expression<DT>, provided by the ArithmeticAggregates extension

Return the average of all non-null values in this group.
avg({Expression<bool>? filter}) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeAggregate extension

Return the average of all non-null values in this group. To only consider rows matching a predicate, you can set the optional filter. Note that filter is only available from sqlite 3.30, released on 2019-10-04. Most devices will use an older sqlite version.
avg({Expression<bool>? filter}) Expression<double>

Available on Expression<BigInt>, provided by the BigIntAggregates extension

Return the average of all non-null values in this group.
bitwiseAnd(Expression<int> other) Expression<int>

Available on Expression<int>, provided by the BitwiseInt extension

Returns the bitwise-and operation between this and other.
bitwiseAnd(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the BitwiseBigInt extension

Returns the bitwise-and operation between this and other.
bitwiseOr(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the BitwiseBigInt extension

Returns the bitwise-or operation between this and other.
bitwiseOr(Expression<int> other) Expression<int>

Available on Expression<int>, provided by the BitwiseInt extension

Returns the bitwise-or operation between this and other.
caseMatch<T extends Object>({required Map<Expression<R>, Expression<T>> when, Expression<T>? orElse}) Expression<T>
A CASE WHEN construct using the current expression as a base.
inherited
cast<D2 extends Object>([BaseSqlType<D2>? type]) Expression<D2>
Generates a CAST(expression AS TYPE) expression.
inherited
collate(Collate collate) Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Uses the given collate sequence when comparing this column to other values.
contains(String substring) Expression<bool>

Available on Expression<String>, provided by the StringExpressionOperators extension

Whether this expression contains substring.
containsCase(String substring, {bool caseSensitive = false}) Expression<bool>

Available on Expression<String>, provided by the DriftNativeStringExtensions extension

Version of contains that allows controlling case sensitivity better.
count({bool distinct = false, Expression<bool>? filter}) Expression<int>

Available on Expression<DT>, provided by the BaseAggregate extension

Returns how often this expression is non-null in the current group.
dartCast<D2 extends Object>({CustomSqlType<D2>? customType}) Expression<D2>
Casts this expression to an expression of D.
inherited
equals(R 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<R> compare) Expression<bool>
Whether this expression is equal to the given expression.
inherited
equalsNullable(R? compare) Expression<bool>
Compares the value of this column to compare or null.
inherited
groupConcat({String separator = ',', bool distinct = false, Expression<bool>? filter}) Expression<String>

Available on Expression<DT>, provided by the BaseAggregate extension

Returns the concatenation of all non-null values in the current group, joined by the separator.
iif<T extends Object>(Expression<bool> predicate, Expression<T> ifFalse) Expression<T>
Evaluates to this if predicate is true, otherwise evaluates to ifFalse.
inherited
isBetween(Expression<DT> lower, Expression<DT> higher, {bool not = false}) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression evaluating to true if this expression is between lower and higher (both inclusive).
isBetweenValues(DT lower, DT higher, {bool not = false}) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression evaluating to true if this expression is between lower and higher (both inclusive).
isBiggerOrEqual(Expression<DT> other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is bigger than or equal to he other expression.
isBiggerOrEqualValue(DT other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is bigger than or equal to he other value.
isBiggerThan(Expression<DT> other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is strictly bigger than the other expression.
isBiggerThanValue(DT other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is strictly bigger than the other value.
isExp(Expression<R> other) Expression<bool>
Generates an IS expression in SQL, comparing this expression with the other expression.
inherited
isIn(Iterable<R> values) Expression<bool>
An expression that is true if this resolves to any of the values in values.
inherited
isInExp(List<Expression<R>> expressions) Expression<bool>
An expression that evaluates to true if this expression resolves to a value that one of the expressions resolve to as well.
inherited
isInQuery(BaseSelectStatement select) Expression<bool>
An expression checking whether this is included in any row of the provided select statement.
inherited
isNotExp(Expression<R> other) Expression<bool>
Generates an IS NOT expression in SQL, comparing this expression with the other expression.
inherited
isNotIn(Iterable<R> values) Expression<bool>
An expression that is true if this does not resolve to any of the values in values.
inherited
isNotInExp(List<Expression<R>> expressions) Expression<bool>
An expression that evaluates to true if this expression does not resolve to any value that the expressions resolve to.
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(R 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
isSmallerOrEqual(Expression<DT> other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is smaller than or equal to he other expression.
isSmallerOrEqualValue(DT other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is smaller than or equal to he other value.
isSmallerThan(Expression<DT> other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is strictly smaller than the other expression.
isSmallerThanValue(DT other) Expression<bool>

Available on Expression<DT>, provided by the ComparableExpr extension

Returns an expression that is true if this expression is strictly smaller than the other value.
isValue(R value) Expression<bool>
Generates an IS expression in SQL, comparing this expression with the Dart value.
inherited
json() Expression<String>

Available on Expression<String>, provided by the JsonExtensions extension

Reads this expression as a JSON structure and outputs the JSON in a minified format.
json() Expression<String>

Available on Expression<Uint8List>, provided by the JsonbExtensions extension

Reads this binary JSONB structure and emits its textual representation as minified JSON.
jsonArrayLength([String? path]) Expression<int>

Available on Expression<String>, provided by the JsonExtensions extension

Assuming that this string is a json array, returns the length of this json array.
jsonArrayLength([String? path]) Expression<int>

Available on Expression<Uint8List>, provided by the JsonbExtensions extension

Assuming that this is an expression evaluating to a binary JSONB array, returns the length of the array.
jsonb() Expression<Uint8List>

Available on Expression<String>, provided by the JsonExtensions extension

Reads this expression as a JSON structure and outputs the JSON in a binary format internal to sqlite3.
jsonEach(DatabaseConnectionUser database, [String? path]) JsonTableFunction

Available on Expression<Uint8List>, provided by the JsonbExtensions extension

Calls the json_each table-valued function on this binary JSON buffer, optionally using path as the root path.
jsonEach(DatabaseConnectionUser database, [String? path]) JsonTableFunction

Available on Expression<String>, provided by the JsonExtensions extension

Calls the json_each table-valued function on this string, optionally using path as the root path.
jsonExtract<T extends Object>(String path) Expression<T>

Available on Expression<Uint8List>, provided by the JsonbExtensions extension

Assuming that this is an expression evaluating to a binary JSONB object or array, extracts the part of the structure identified by path.
jsonExtract<T extends Object>(String path) Expression<T>

Available on Expression<String>, provided by the JsonExtensions extension

Assuming that this string is a json object or array, extracts a part of this structure identified by path.
jsonTree(DatabaseConnectionUser database, [String? path]) JsonTableFunction

Available on Expression<String>, provided by the JsonExtensions extension

Calls the json_tree table-valued function on this string, optionally using path as the root path.
jsonTree(DatabaseConnectionUser database, [String? path]) JsonTableFunction

Available on Expression<Uint8List>, provided by the JsonbExtensions extension

Calls the json_tree table-valued function on this binary JSON buffer, optionally using path as the root path.
like(String regex) Expression<bool>

Available on Expression<String>, provided by the StringExpressionOperators extension

Whether this column matches the given pattern. For details on what patters are valid and how they are interpreted, check out this tutorial.
likeExp(Expression<String> regex) Expression<bool>

Available on Expression<String>, provided by the StringExpressionOperators extension

Whether this column matches the given expression. For details on what patters are valid and how they are interpreted, check out this tutorial.
lower() Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Calls the sqlite function LOWER on this string. Please note that, in most sqlite installations, this only affects ascii chars.
max({Expression<bool>? filter}) Expression<BigInt>

Available on Expression<BigInt>, provided by the BigIntAggregates extension

Return the maximum of all non-null values in this group.
max({Expression<bool>? filter}) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeAggregate extension

Return the maximum of all non-null values in this group.
max({Expression<bool>? filter}) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticAggregates extension

Return the maximum of all non-null values in this group.
max({Expression<bool>? filter}) Expression<DT>

Available on Expression<DT>, provided by the BaseAggregate extension

Return the maximum of all non-null values in this group.
min({Expression<bool>? filter}) Expression<BigInt>

Available on Expression<BigInt>, provided by the BigIntAggregates extension

Return the minimum of all non-null values in this group.
min({Expression<bool>? filter}) Expression<DT>

Available on Expression<DT>, provided by the BaseAggregate extension

Return the minimum of all non-null values in this group.
min({Expression<bool>? filter}) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeAggregate extension

Return the minimum of all non-null values in this group.
min({Expression<bool>? filter}) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticAggregates extension

Return the minimum of all non-null values in this group.
modify(DateTimeModifier modifier) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Apply a modifier that alters the date and/or time.
modifyAll(Iterable<DateTimeModifier> modifiers) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Applies modifiers that alters the date and/or time.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
not() Expression<bool>

Available on Expression<bool>, provided by the BooleanExpressionOperators extension

Negates this boolean expression. The returned expression is true if this is false, and vice versa.
nullIf(Expression<R> matcher) Expression<R>
Returns null if matcher is equal to this expression, this otherwise.
inherited
regexp(String regex, {bool multiLine = false, bool caseSensitive = true, bool unicode = false, bool dotAll = false}) Expression<bool>

Available on Expression<String>, provided by the StringExpressionOperators extension

Matches this string against the regular expression in regex.
roundToInt() Expression<int>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Rounds this expression to the nearest integer.
roundToInt() Expression<int>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Rounds this expression to the nearest integer.
strftime(String format) Expression<String>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Formats this datetime according to the format string specified as the first argument. The format string supports the most common substitutions found in the strftime() function from the standard C library plus two new substitutions, %f and %J. The following is a complete list of valid strftime() substitutions:
substr(int start, [int? length]) Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Calls the substr function on this string.
substrExpr(Expression<int> start, [Expression<int>? length]) Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Calls the substr function with arbitrary expressions as arguments.
sum({Expression<bool>? filter}) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticAggregates extension

Calculate the sum of all non-null values in the group.
sum({Expression<bool>? filter}) Expression<BigInt>

Available on Expression<BigInt>, provided by the BigIntAggregates extension

Calculate the sum of all non-null values in the group.
toString() String
A string representation of this object.
inherited
total({Expression<bool>? filter}) Expression<double>

Available on Expression<BigInt>, provided by the BigIntAggregates extension

Calculate the sum of all non-null values in the group.
total({Expression<bool>? filter}) Expression<double>

Available on Expression<DT>, provided by the ArithmeticAggregates extension

Calculate the sum of all non-null values in the group.
trim() Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Removes spaces from both ends of this string.
trimLeft() Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Removes spaces from the beginning of this string.
trimRight() Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Removes spaces from the end of this string.
upper() Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Calls the sqlite function UPPER on this string. Please note that, in most sqlite installations, this only affects ascii chars.
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.
inherited

Operators

operator &(Expression<bool> other) Expression<bool>

Available on Expression<bool>, provided by the BooleanExpressionOperators extension

Returns an expression that is true iff both this and other are true.
operator *(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Performs a multiplication (this * other) in sql.
operator *(Expression<DT> other) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Performs a multiplication (this * other) in sql.
operator +(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Performs an addition (this + other) in sql.
operator +(Expression<DT> other) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Performs an addition (this + other) in sql.
operator +(Duration duration) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Adds a duration to this date.
operator +(Expression<String> other) Expression<String>

Available on Expression<String>, provided by the StringExpressionOperators extension

Performs a string concatenation in sql by appending other to this.
operator -(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Performs a subtraction (this - other) in sql.
operator -(Expression<DT> other) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Performs a subtraction (this - other) in sql.
operator -(Duration duration) Expression<DateTime>

Available on Expression<DateTime>, provided by the DateTimeExpressions extension

Subtracts duration from this date.
operator /(Expression<BigInt> other) Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Performs a division (this / other) in sql.
operator /(Expression<DT> other) Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Performs a division (this / other) in sql.
operator ==(Object other) bool
The equality operator.
inherited
operator unary-() Expression<BigInt>

Available on Expression<BigInt>, provided by the ArithmeticBigIntExpr extension

Returns the negation of this value.
operator unary-() Expression<DT>

Available on Expression<DT>, provided by the ArithmeticExpr extension

Returns the negation of this value.
operator |(Expression<bool> other) Expression<bool>

Available on Expression<bool>, provided by the BooleanExpressionOperators extension

Returns an expression that is true if this or other are true.
operator ~() Expression<BigInt>

Available on Expression<BigInt>, provided by the BitwiseBigInt extension

Flips all bits in this value (turning 0 to 1 and vice-versa) and returns the result.
operator ~() Expression<int>

Available on Expression<int>, provided by the BitwiseInt extension

Flips all bits in this value (turning 0 to 1 and vice-versa) and returns the result.