query_builder library Null safety

Classes

BaseSelectStatement
The abstract base class for all select statements in the drift api.
Component
A component is anything that can appear in a sql query.
Constant<T>
An expression that represents the value of a dart object encoded to sql by writing them into the sql statements. For most cases, consider using Variable instead.
CustomExpression<D>
A custom expression that can appear in a sql statement. The CustomExpression.content will be written into the query without any modification.
CustomSelectStatement
A select statement that is constructed with a raw sql prepared statement instead of the high-level drift api.
DatabaseSchemaEntity
Some abstract schema entity that can be stored in a database. This includes tables, triggers, views, indexes, etc.
DeleteStatement<T extends dynamic, D>
A DELETE statement in sql
DoUpdate<T extends dynamic, D>
A DoUpdate upsert clause can be used to insert or update a custom companion when the underlying companion already exists.
Expression<D>
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.
FunctionCallExpression<R>
A sql expression that calls a function.
FunctionParameter
Base class for everything that can be used as a function parameter in sql.
GeneratedAs
Information filled out by the generator to support generated or virtual columns.
GeneratedColumn<T>
Implementation for a Column declared on a table.
GeneratedColumnWithTypeConverter<D, S>
A GeneratedColumn with a type converter attached to it.
GenerationContext
Contains information about a query while it's being constructed.
GroupBy
A "group by" clause in sql.
Index
A sqlite index on columns or expressions.
InsertStatement<T extends dynamic, D>
Represents an insert statement
Join<T extends dynamic, D>
Used internally by drift when calling SimpleSelectStatement.join.
JoinedSelectStatement<FirstT extends dynamic, FirstD>
A SELECT statement that operates on more than one table.
Limit
A limit clause inside a select, update or delete statement.
MigrationStrategy
Handles database migrations by delegating work to OnCreate and OnUpgrade methods.
Migrator
Runs migrations declared by a MigrationStrategy.
MultiSelectable<T>
Selectable methods for returning multiple results.
OnCreateQuery
An internal schema entity to run an sql statement when the database is created.
OpeningDetails
Provides information about whether migrations ran before opening the database.
OrderBy
An order-by clause as part of a select statement. The clause can consist of multiple OrderingTerms, with the first terms being more important and the later terms only being considered if the first term considers two rows equal.
OrderingTerm
A single term in a OrderBy clause. The priority of this term is determined by its position in OrderBy.terms.
Precedence
Used to order the precedence of sql expressions so that we can avoid unnecessary parens when generating sql statements.
Query<T extends dynamic, D>
Statement that operates with data that already exists (select, delete, update).
QueryRow
For custom select statements, represents a row in the result set.
ResultSetImplementation<Tbl, Row>
Interface for schema entities that have a result set.
Selectable<T>
Abstract class for queries which can return one-time values or a stream of values.
SimpleSelectStatement<T extends dynamic, D>
A select statement that doesn't use joins.
SingleOrNullSelectable<T>
Selectable methods for returning or streaming single, nullable results.
SingleSelectable<T>
Selectable methods for returning or streaming single, non-nullable results.
TableMigration
Contains instructions needed to run a complex migration on a table, using the steps described in Making other kinds of table schema changes.
Trigger
A sqlite trigger that's executed before, after or instead of a subset of writes on a specific tables. In drift, triggers can only be declared in .drift files.
TypedResult
A result row in a JoinedSelectStatement that can parse the result of multiple entities.
UpdateStatement<T extends dynamic, D>
Represents an UPDATE statement in sql.
UpsertClause<T extends dynamic, D>
A upsert clause controls how to behave when a uniqueness constraint is violated during an insert.
UpsertMultiple<T extends dynamic, D>
Upsert clause that consists of multiple clauses.
Variable<T>
An expression that represents the value of a dart object encoded to sql using prepared statements.
ViewInfo<Self extends dynamic, Row>
A sqlite view.
Where
A where clause in a select, update or delete statement.

Mixins

LimitContainerMixin<T extends dynamic, D>
Mixin to provide the high-level limit methods for users.
SingleTableQueryMixin<T extends dynamic, D>
Mixin for a Query that operates on a single primary table only.
TableInfo<TableDsl extends dynamic, D>
Base class for generated table classes.
VirtualTableInfo<TableDsl extends dynamic, D>
Additional interface for tables in a drift file that have been created with an CREATE VIRTUAL TABLE STATEMENT.

Extensions

ArithmeticAggregates
Provides aggregate functions that are available for numeric expressions.
ArithmeticBigIntExpr
Defines the -, * and / operators on sql expressions that support it.
ArithmeticExpr
Defines the -, * and / operators on sql expressions that support it.
BaseAggregate
Provides aggregate functions that are available for each expression.
BigIntAggregates
Provides aggregate functions that are available for BigInt expressions.
BooleanExpressionOperators
Defines operations on boolean values.
ComparableExpr
Defines extension functions to express comparisons in sql
DateTimeAggregate
Provides aggregate functions that are available on date time expressions.
DateTimeExpressions
Provides expressions to extract information from date time values, or to calculate the difference between datetimes.
DestructiveMigrationExtension
Extension providing the destructiveFallback strategy.
NameWithAlias
Extension to generate an alias for a table or a view.
QueryTableExtensions
Extension for statements on a table.
RowIdExtension
Extension to use the rowid of a table in Dart queries.
SqlIsNull
Extension defines the isNull and isNotNull members to check whether the expression evaluates to null or not.
StringExpressionOperators
Defines methods that operate on a column storing String values.
TableInfoUtils
Static extension members for generated table classes.
TableOrViewStatements
Easily-accessible methods to compose common operations or statements on tables or views.
TableStatements
Easily-accessible methods to compose common operations or statements on tables.

Constants

currentDate → const Expression<DateTime>
A sql expression that evaluates to the current date represented as a unix timestamp. The hour, minute and second fields will be set to 0.
_CustomDateTimeExpression("strftime('%s', CURRENT_DATE)")
currentDateAndTime → const Expression<DateTime>
A sql expression that evaluates to the current date and time, similar to DateTime.now. Timestamps are stored with a second accuracy.
_CustomDateTimeExpression("strftime('%s', CURRENT_TIMESTAMP)")

Functions

coalesce<T>(List<Expression<T?>> expressions) Expression<T>
Evaluates to the first expression in expressions that's not null, or null if all expressions evaluate to null.
countAll({Expression<bool?>? filter}) Expression<int>
Returns the amount of rows in the current group matching the optional filter.
crossJoin(dynamic other, {bool? useColumns}) Join
Creates a sql cross join that can be used in SimpleSelectStatement.join.
existsQuery(BaseSelectStatement select) Expression<bool>
The EXISTS operator checks whether the select subquery returns any rows.
innerJoin(dynamic other, Expression<bool?> on, {bool? useColumns}) Join
Creates a sql inner join that can be used in SimpleSelectStatement.join.
isNotNull(Expression inner) Expression<bool>
Expression that is true if the inner expression resolves to a non-null value.
@Deprecated('Use isNotNull through the SqlIsNull extension')
isNull(Expression inner) Expression<bool>
Expression that is true if the inner expression resolves to a null value.
@Deprecated('Use isNull through the SqlIsNull extension')
leftOuterJoin(dynamic other, Expression<bool?> on, {bool? useColumns}) Join
Creates a sql left outer join that can be used in SimpleSelectStatement.join.
notExistsQuery(BaseSelectStatement select) Expression<bool>
The NOT EXISTS operator evaluates to true if the select subquery does not return any rows.
subqueryExpression<R>(BaseSelectStatement statement) Expression<R>
Creates a subquery expression from the given statement.

Enums

Collate
Builtin collating functions from sqlite.
InsertMode
Enumeration of different insert behaviors. See the documentation on the individual fields for details.
OrderingMode
Describes how to order rows
SqlDialect
An enumeration of database systems supported by drift. Only SqlDialect.sqlite is officially supported, all others are in an experimental state at the moment.

Typedefs

OnBeforeOpen = Future<void> Function(OpeningDetails details)
Signature of a function that's called before a database is marked opened by drift, but after migrations took place. This is a suitable callback to to populate initial data or issue PRAGMA statements that you want to use.
OnCreate = Future<void> Function(Migrator m)
Signature of a function that will be invoked when a database is created.
OnUpgrade = Future<void> Function(Migrator m, int from, int to)
Signature of a function that will be invoked when a database is upgraded or downgraded. In version upgrades: from < to In version downgrades: from > to
OrderClauseGenerator<T> = OrderingTerm Function(T tbl)
Signature of a function that generates an OrderingTerm when provided with a table.