drift library Null safety


Instruction to run a batched sql statement with the arguments provided.
The abstract base class for all select statements in the drift api.
Contains operations to run queries in a batched mode.
Stores information needed to run batched statements in the order they were issued without preparing statements multiple times.
Collating functions used to compare texts in SQL.
Column<T extends Object>
Base class for columns in sql. Type T refers to the type a value of this column will have in Dart.
ColumnBuilder<T extends Object>
A column builder is used to specify which columns should appear in a table. All of the methods defined in this class and its subclasses are not meant to be called at runtime. Instead, the generator will take a look at your source code (specifically, it will analyze which of the methods you use) to figure out the column structure of a table.
A component is anything that can appear in a sql query.
Constant<T extends Object>
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 extends Object>
A custom expression that can appear in a sql statement. The CustomExpression.content will be written into the query without any modification.
Base class for classes generated by custom queries in .drift files.
A select statement that is constructed with a raw sql prepared statement instead of the high-level drift api.
DatabaseAccessor<T extends GeneratedDatabase>
Class that runs queries to a subset of all available queries in a database.
A database connection managed by drift. This consists of two components:
Manages a DatabaseConnection to send queries to the database.
Some abstract schema entity that can be stored in a database. This includes tables, triggers, views, indexes, etc.
A common supertype for all data classes generated by drift. Data classes are immutable structures that represent a single row in a database table.
A class to be used as an annotation on Table classes to customize the name for the data class that will be generated for the table class. The data class is a dart object that will be used to represent a row in the table.
DateTime modifier constants.
DeleteStatement<T extends Table, D>
A DELETE statement in sql
DoUpdate<T extends Table, D>
A DoUpdate upsert clause can be used to insert or update a custom companion when the underlying companion already exists.
Annotation to use on classes that implement DatabaseAccessor. It specifies which tables should be made available in this dao.
Use this class as an annotation to inform the generator that a database class should be generated using the specified DriftDatabase.tables.
Database-specific options used by drift.
Defines additional runtime behavior for drift. Changing the fields of this class is rarely necessary.
An annotation specifying view properties
EnumIndexConverter<T extends Enum>
Implementation for an enum to int converter that uses the index of the enum as the value stored in the database.
Expression<D extends Object>
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 extends Object>
A sql expression that calls a function.
Base class for everything that can be used as a function parameter in sql.
Information filled out by the generator to support generated or virtual columns.
GeneratedColumn<T extends Object>
Implementation for a Column declared on a table.
GeneratedColumnWithTypeConverter<D, S extends Object>
A GeneratedColumn with a type converter attached to it.
A base class for all generated databases.
Contains information about a query while it's being constructed.
A "group by" clause in sql.
Base class for dsl Tables and Views.
A sqlite index on columns or expressions.
Common interface for objects which can be inserted or updated into a database. D is the associated data class.
InsertStatement<T extends Table, D>
Represents an insert statement
Join<T extends HasResultSet, D>
Used internally by drift when calling SimpleSelectStatement.join.
JoinedSelectStatement<FirstT extends HasResultSet, FirstD>
A SELECT statement that operates on more than one table.
Annotation to use on column getters inside of a Table to define the name of the column in the json used by DataClass.toJson.
A special database executor that delegates work to another QueryExecutor. The other executor is lazily opened by a DatabaseOpener.
A limit clause inside a select, update or delete statement.
Handles database migrations by delegating work to OnCreate and OnUpgrade methods.
Runs migrations declared by a MigrationStrategy.
A query executor for drift that delegates work to multiple executors.
Selectable methods for returning multiple results.
NullAwareTypeConverter<D, S extends Object>
A type converter automatically mapping null values to null in both directions.
An internal schema entity to run an sql statement when the database is created.
Provides information about whether migrations ran before opening the database.
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.
A single term in a OrderBy clause. The priority of this term is determined by its position in OrderBy.terms.
Used to order the precedence of sql expressions so that we can avoid unnecessary parens when generating sql statements.
Query<T extends HasResultSet, D>
Statement that operates with data that already exists (select, delete, update).
A query executor is responsible for executing statements on a database and return their results in a raw form.
Callbacks passed to QueryExecutor.ensureOpen to run schema migrations when the database is first opened.
For custom select statements, represents a row in the result set.
An Insertable implementation based on raw column expressions.
ResultSetImplementation<Tbl, Row>
Interface for schema entities that have a result set.
Abstract class for queries which can return one-time values or a stream of values.
SimpleSelectStatement<T extends HasResultSet, D>
A select statement that doesn't use joins.
Selectable methods for returning or streaming single, nullable results.
Selectable methods for returning or streaming single, non-nullable results.
Database-specific helper methods mapping Dart values from and to SQL variables or literals.
Collects a set of UpdateRules which can be used to express how a set of direct updates to a table affects other updates.
Subclasses represent a table in a database generated by drift.
Contains instructions needed to run a complex migration on a table, using the steps described in Making other kinds of table schema changes.
Contains information on how a table was updated, which can be used to find queries that are affected by this.
A table update query describes information to listen for TableUpdates.
A QueryExecutor that runs multiple queries atomically.
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.
TypeConverter<D, S>
Maps a custom dart object of type D into a primitive type S understood by the sqlite backend.
A result row in a JoinedSelectStatement that can parse the result of multiple entities.
A fixed-length list of 8-bit unsigned integers.
An update companion for a DataClass which is used to write data into a database using InsertStatement.insert or UpdateStatement.write.
A common rule that describes how a TableUpdate has other TableUpdates.
UpdateStatement<T extends Table, D>
Represents an UPDATE statement in sql.
UpsertClause<T extends Table, D>
A upsert clause controls how to behave when a uniqueness constraint is violated during an insert.
UpsertMultiple<T extends Table, D>
Upsert clause that consists of multiple clauses.
An annotation specifying an existing class to be used as a data class.
A wrapper around arbitrary data T to indicate presence or absence explicitly.
Serializer responsible for mapping atomic types from and to json.
Variable<T extends Object>
An expression that represents the value of a dart object encoded to sql using prepared statements.
Used internally by drift for integrity checks.
Additional information that is passed to GeneratedColumns when verifying data to provide more helpful error messages.
Returned by GeneratedColumn.isAcceptableValue to provide a description when a valid is invalid.
Subclasses represent a view in a database generated by drift.
ViewInfo<Self extends HasResultSet, Row>
A sqlite view.
VirtualColumnBuilder<T extends Object>
A column builder for virtual, generated columns.
A where clause in a select, update or delete statement.
An UpdateRule for triggers that exist in a database.


JsonTypeConverter<D, S>
A mixin for TypeConverters that should also apply to drift's builtin JSON serialization of data classes.
JsonTypeConverter2<D, S, J>
A mixin for TypeConverters that should also apply to drift's builtin JSON serialization of data classes.
LimitContainerMixin<T extends HasResultSet, D>
Mixin to provide the high-level limit methods for users.
SingleTableQueryMixin<T extends HasResultSet, D>
Mixin for a Query that operates on a single primary table only.
TableInfo<TableDsl extends Table, D>
Base class for generated table classes.
VirtualTableInfo<TableDsl extends Table, D>
Additional interface for tables in a drift file that have been created with an CREATE VIRTUAL TABLE STATEMENT.


Provides aggregate functions that are available for numeric expressions.
Defines the -, * and / operators on sql expressions that support it.
Defines the -, * and / operators on sql expressions that support it.
Provides aggregate functions that are available for each expression.
Provides aggregate functions that are available for BigInt expressions.
Extensions providing bitwise operators ~, on integer expressions that are represented as a Dart BigInt.
Extensions providing bitwise operators ~, on integer expressions.
Defines operations on boolean values.
DSL extension to define a column inside a drift table.
Column builders available for both virtual and non-virtual columns.
Tells the generator to build an IntColumn. See the docs at ColumnBuilder for details.
Tells the generator to build an TextColumn. See the docs at ColumnBuilder for details.
Defines extension functions to express comparisons in sql
Provides aggregate functions that are available on date time expressions.
Provides expressions to extract information from date time values, or to calculate the difference between datetimes.
Extension providing the destructiveFallback strategy.
Extension to generate an alias for a table or a view.
Extension for generated dao classes to keep the old db field that was renamed to DatabaseAccessor.attachedDatabase in drift 3.0
Extension for statements on a table.
Extension to use the rowid of a table in Dart queries.
Extension defines the isNull and isNotNull members to check whether the expression evaluates to null or not.
Defines methods that operate on a column storing String values.
Static extension members for generated table classes.
Easily-accessible methods to compose common operations or statements on tables or views.
Easily-accessible methods to compose common operations or statements on tables.


$driftBlobEquality → const ListEquality
A ListEquality instance used by generated drift code for the == and Object.hashCode implementation of generated classes if they contain lists.
currentDate → const Expression<DateTime>
A sql expression that evaluates to the current date.
_DependingOnDateTimeExpression(forIsoString: _currentDateLiteral, forTimestamps: _DartCastExpression(FunctionCallExpression('strftime', [Constant('%s'), _currentDateLiteral])))
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.
_DependingOnDateTimeExpression(forIsoString: _currentTimestampLiteral, forTimestamps: _CastInSqlExpression(FunctionCallExpression('strftime', [Constant('%s'), _currentTimestampLiteral]…


driftRuntimeOptions DriftRuntimeOptions
Stores the DriftRuntimeOptions describing global drift behavior across databases.
read / write


coalesce<T extends Object>(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(Table other, {bool? useColumns}) Join<HasResultSet, dynamic>
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(Table other, Expression<bool> on, {bool? useColumns}) Join<HasResultSet, dynamic>
Creates a sql inner join that can be used in SimpleSelectStatement.join.
isNotNull(Expression<Object> 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<Object> inner) Expression<bool>
Expression that is true if the inner expression resolves to a null value.
@Deprecated('Use isNull through the SqlIsNull extension')
leftOuterJoin(Table other, Expression<bool> on, {bool? useColumns}) Join<HasResultSet, dynamic>
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 extends Object>(BaseSelectStatement statement) Expression<R>
Creates a subquery expression from the given statement.


DriftSqlType<T extends Object>
An enumation of type mappings that are builtin to drift and drift_dev.
Enumeration of different insert behaviors. See the documentation on the individual fields for details.
A KeyAction can be used on a BuildColumn.references clause to describe how updates and deletes to a referenced table should propagate in your database.
Describes how to order nulls
Describes how to order rows
An enumeration of database systems supported by drift. Only SqlDialect.sqlite is officially supported, all others are in an experimental state at the moment.
Classifies a TableUpdate by what kind of write happened - an insert, an update or a delete operation.


BlobColumn = Column<Uint8List>
A column that stores arbitrary blobs of data as a Uint8List.
BoolColumn = Column<bool>
A column that stores boolean values. Booleans will be stored as an integer that can either be 0 (false) or 1 (true).
DatabaseOpener = FutureOr<QueryExecutor> Function()
Signature of a function that opens a database connection when instructed to.
DateTimeColumn = Column<DateTime>
A column that stores a DateTime. Times will be stored as unix timestamp and will thus have a second accuracy.
Int64Column = Column<BigInt>
A column that stores BigInt values.
IntColumn = Column<int>
A column that stores int values.
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.
RealColumn = Column<double>
A column that stores floating point numeric values.
TextColumn = Column<String>
A column that stores text.

Exceptions / Errors

Exception thrown by drift when rolling back a transaction fails.
A wrapper class for internal exceptions thrown by the underlying database engine when drift can give additional context or help.
Thrown when one attempts to insert or update invalid data into a table.