DateTimeModifier class final
DateTime modifier constants.
These modifiers are used on DateTimeExpressions.modify and DateTimeExpressions.modifyAll to apply transformations on date time values.
For instance, DateTimeModifier.days can be used to add or subtract calendar days from a date time value. Note that this is different from just subtracting a duration with DateTimeExpressions.+, which only adds a duration as seconds without respecting calendar units.
For another explanation of modifiers, see the sqlite3 docs.
- Inheritance
-
- Object
- Expression<
String> - Constant<
String> - DateTimeModifier
- Available extensions
Constructors
- DateTimeModifier.days(int days)
-
Adds or subtracts
days
calendar days from the date time value.const - DateTimeModifier.hours(int hours)
-
Adds or subtracts
hours
hours from this date time value.const - DateTimeModifier.localTime()
-
Move a date time that is in UTC to the local time zone.
const
- DateTimeModifier.minutes(int minutes)
-
Adds or subtracts
minutes
minutes from this date time value.const - DateTimeModifier.months(int months)
-
Adds or subtracts
months
months from this date time value.const - DateTimeModifier.seconds(num seconds)
-
Adds or subtracts
seconds
seconds from this date time value.const - DateTimeModifier.startOfDay()
-
The "start of day" modifier shifts the date backwards to the beginning of
the day.
const
- DateTimeModifier.startOfMonth()
-
The "start of month" modifier shifts the date backwards to the beginning
of the month.
const
- DateTimeModifier.startOfYear()
-
The "start of year" modifier shifts the date backwards to the beginning of
the year.
const
- DateTimeModifier.utc()
-
Move a date time that is in the local time zone back to UTC.
const
- DateTimeModifier.weekday(int weekday)
-
The "weekday" modifier shifts the date forward to the next date where the
weekday is the
weekday
provided here. - DateTimeModifier.years(int years)
-
Adds or subtracts
years
years from this date time value.const
Properties
-
driftSqlType
→ BaseSqlType<
String> -
The
BaseSqlType
backing this expression.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- isLiteral → bool
-
Whether this expression is a literal. Some use-sites need to put
parentheses around non-literals.
no setterinherited
-
length
→ Expression<
int> -
Available on Expression<
Calls the sqlite functionString> , provided by the StringExpressionOperators extensionLENGTH
onthis
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 - 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
- value → String?
-
The value that will be converted to an sql literal.
finalinherited
Methods
-
caseMatch<
T extends Object> ({required Map< Expression< when, Expression<String> , Expression<T> >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<
Uses the givenString> , provided by the StringExpressionOperators extensioncollate
sequence when comparing this column to other values. -
contains(
String substring) → Expression< bool> -
Available on Expression<
Whether this expression containsString> , provided by the StringExpressionOperators extensionsubstring
. -
containsCase(
String substring, {bool caseSensitive = false}) → Expression< bool> -
Available on Expression<
Version ofString> , provided by the DriftNativeStringExtensions extensioncontains
that allows controlling case sensitivity better. -
dartCast<
D2 extends Object> ({CustomSqlType< D2> ? customType}) → Expression<D2> -
Casts this expression to an expression of
D
.inherited -
equals(
String 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< String> compare) → Expression<bool> -
Whether this expression is equal to the given expression.
inherited
-
equalsNullable(
String? compare) → Expression< bool> -
Compares the value of this column to
compare
ornull
.inherited -
iif<
T extends Object> (Expression< bool> predicate, Expression<T> ifFalse) → Expression<T> -
Evaluates to
this
ifpredicate
is true, otherwise evaluates toifFalse
.inherited -
isExp(
Expression< String> other) → Expression<bool> -
Generates an
IS
expression in SQL, comparing this expression with theother
expression.inherited -
isIn(
Iterable< String> values) → Expression<bool> -
An expression that is true if
this
resolves to any of the values invalues
.inherited -
isInExp(
List< Expression< expressions) → Expression<String> >bool> -
An expression that evaluates to
true
if this expression resolves to a value that one of theexpressions
resolve to as well.inherited -
isInQuery(
BaseSelectStatement select) → Expression< bool> -
An expression checking whether
this
is included in any row of the providedselect
statement.inherited -
isNotExp(
Expression< String> other) → Expression<bool> -
Generates an
IS NOT
expression in SQL, comparing this expression with theother
expression.inherited -
isNotIn(
Iterable< String> values) → Expression<bool> -
An expression that is true if
this
does not resolve to any of the values invalues
.inherited -
isNotInExp(
List< Expression< expressions) → Expression<String> >bool> -
An expression that evaluates to
true
if this expression does not resolve to any value that theexpressions
resolve to.inherited -
isNotInQuery(
BaseSelectStatement select) → Expression< bool> -
An expression checking whether
this
is not included in any row of the providedselect
statement.inherited -
isNotNull(
) → Expression< bool> -
Expression that is true if the inner expression resolves to a non-null
value.
inherited
-
isNotValue(
String value) → Expression< bool> -
Generates an
IS NOT
expression in SQL, comparing this expression with the Dartvalue
.inherited -
isNull(
) → Expression< bool> -
Expression that is true if the inner expression resolves to a null value.
inherited
-
isValue(
String value) → Expression< bool> -
Generates an
IS
expression in SQL, comparing this expression with the Dartvalue
.inherited -
json(
) → Expression< String> -
Available on Expression<
ReadsString> , provided by the JsonExtensions extensionthis
expression as a JSON structure and outputs the JSON in a minified format. -
jsonArrayLength(
[String? path]) → Expression< int> -
Available on Expression<
Assuming that this string is a json array, returns the length of this json array.String> , provided by the JsonExtensions extension -
jsonb(
) → Expression< Uint8List> -
Available on Expression<
ReadsString> , provided by the JsonExtensions extensionthis
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<
Calls theString> , provided by the JsonExtensions extensionjson_each
table-valued function onthis
string, optionally usingpath
as the root path. -
jsonExtract<
T extends Object> (String path) → Expression< T> -
Available on Expression<
Assuming that this string is a json object or array, extracts a part of this structure identified byString> , provided by the JsonExtensions extensionpath
. -
jsonTree(
DatabaseConnectionUser database, [String? path]) → JsonTableFunction -
Available on Expression<
Calls theString> , provided by the JsonExtensions extensionjson_tree
table-valued function onthis
string, optionally usingpath
as the root path. -
like(
String regex) → Expression< bool> -
Available on Expression<
Whether this column matches the given pattern. For details on what patters are valid and how they are interpreted, check out this tutorial.String> , provided by the StringExpressionOperators extension -
likeExp(
Expression< String> regex) → Expression<bool> -
Available on Expression<
Whether this column matches the given expression. For details on what patters are valid and how they are interpreted, check out this tutorial.String> , provided by the StringExpressionOperators extension -
lower(
) → Expression< String> -
Available on Expression<
Calls the sqlite functionString> , provided by the StringExpressionOperators extensionLOWER
onthis
string. Please note that, in most sqlite installations, this only affects ascii chars. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullIf(
Expression< String> matcher) → Expression<String> -
Returns
null
ifmatcher
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<
Matches this string against the regular expression inString> , provided by the StringExpressionOperators extensionregex
. -
substr(
int start, [int? length]) → Expression< String> -
Available on Expression<
Calls theString> , provided by the StringExpressionOperators extensionsubstr
function on this string. -
substrExpr(
Expression< int> start, [Expression<int> ? length]) → Expression<String> -
Available on Expression<
Calls theString> , provided by the StringExpressionOperators extensionsubstr
function with arbitrary expressions as arguments. -
toString(
) → String -
A string representation of this object.
inherited
-
trim(
) → Expression< String> -
Available on Expression<
Removes spaces from both ends of this string.String> , provided by the StringExpressionOperators extension -
trimLeft(
) → Expression< String> -
Available on Expression<
Removes spaces from the beginning of this string.String> , provided by the StringExpressionOperators extension -
trimRight(
) → Expression< String> -
Available on Expression<
Removes spaces from the end of this string.String> , provided by the StringExpressionOperators extension -
upper(
) → Expression< String> -
Available on Expression<
Calls the sqlite functionString> , provided by the StringExpressionOperators extensionUPPER
onthis
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 ofthis
expression is lower, it will be wrap}ped ininherited -
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< String> other) → Expression<String> -
Available on Expression<
Performs a string concatenation in sql by appendingString> , provided by the StringExpressionOperators extensionother
tothis
. -
operator ==(
Object other) → bool -
The equality operator.
inherited