drift 2.12.0
drift: ^2.12.0 copied to clipboard
Drift is a reactive library to store relational data in Dart and Flutter applications.
2.12.0 #
- Add support for table-valued functions in the Dart query builder.
- Add the
@TableIndexannotation for table classes to add an index to the table. - Support
json_eachandjson_tree. - Add the
TypeConverter.jsonmethod to define type converters storing JSON values more easily. - Add
TypedResult.readWithConverterto read a column with a type converter from a join result row.
2.11.1 #
- Allow using
.read()for a column added to a join from the table, fixing a regression in drift 2.11.0. - Make step-by-step migrations easier to customize with
Migrator.runMigrationSteps.
2.11.0 #
- Add support for subqueries in the Dart query builder.
- Add
isInExpandisNotInExpto constructIS INexpressions with arbitrary expressions. - Add the
substrextension onExpression<String>to call the sqlite3 function from the Dart API. - Add
isolateSetuptoNativeDatabase.createInBackground()to override native libraries or perform other database-unrelated setup work. - Add
WasmDatabase.probe(), a method probing for available implementations and existing databases on the web without opening one directly.
2.10.0 #
- Adds the
schema stepscommand todrift_dev. It generates an API making it easier to write safe schema migrations (docs). - Fix drift WASM not being unusable after a previous database implementation becomes unavailable in the browser.
2.9.0 #
- Forbid
schemaVersionreturning0, as this causes issues in the migrator. - Drift web support is now stable! By using a
WasmDatabase.openfactory as described in https://drift.simonbinder.eu/web/, you can run a drift database in modern browsers!
2.8.2 #
- Fix prepared statements leaking when the statement cache is disabled.
- Disable prepared statement caching by default.
2.8.1 #
- Performance improvement: Cache and re-use prepared statements - thanks to @davidmartos96
- Fix a deadlock after rolling back a transaction in a remote isolate.
- Remove unintended log messages when using
connectToDriftWorker.
2.8.0 #
- Don't keep databases in an unusable state if the
setupcallback throws an exception. Instead, drift will retry the next time the database is used. - Allow targeting partial indices in
DoUpdate(#2394) - Fix deadlocks when
computeWithDatabaseis called inside atransaction().
2.7.0 #
- Add support for
CASEexpressions without a base in the Dart API with theCaseWhenExpressionclass. - Add the new
package:drift/web/workers.dartlibrary which makes it easier to create web workers for drift.
2.6.0 #
- Add
insertReturningOrNullfor potentially empty inserts. - Add
insertFromSelecttoInsertStatementto runINSERT INTO SELECTstatements. - Add
rowidparameter to companions for tables with rowids that don't have a visible alias for the rowid. - After opening a database with a higher schema version than the current one set in the database class, the schema version in the database will now be downgraded.
- When using a drift isolate in the same engine group, errors on the remote end are
reported directly instead of wrapping them in a
DriftRemoteException. - Added support for
DO NOTHINGduring upsert operations with constraint violations
2.5.0 #
- Add
isExp,isValue,isNotExpandisNotValuemethods toExpressionto generate theISoperator in SQL. - Add
all()extension on tables and views to quickly query all rows. - Add
serializableConnection()andcomputeWithDatabase()as extensions on databases. The methods allow sharing any drift database between isolates, regardless of how the database has been set up. - The
DatabaseConnectionclass now implementsQueryExecutor, meaning that you no longer need a special.connect()constructor to use it.
2.4.2 #
- Fix an exception when a client disconnects from a drift remote server while processing a pending table update.
2.4.1 #
- Fix
DriftIsolateleaking resources for closed connections.
2.4.0 #
- Add
textEnumcolumn builder andEnumNameConverterto be able to store enum values as string. - Add
updatesparameter toBatch.customStatement- it can be used to specify which tables are affected by the custom statement. - For
STRICTtables in drift files declaring aANYcolumn, drift will now generate a mapping to the newDriftAnytype. - Add
likeExpto generateLIKEexpression with any comparison expression. - Fix
UNIQUEkeys declared in drift files being written twice. - Fix
customConstraintsnot appearing in dumped database schema files. - Lazily load columns in
TypedResult.read, increasing performance for joins with lots of tables or columns. - Work-around an issue causing complex migrations via
Migrator.alterTablenot to work if a view referenced the altered table.
2.3.0 #
- Add the
JsonTypeConverter2mixin. It behaves similar to the existing json type converters, but can use a different SQL and JSON type. - Add
isInValuesandisNotInValuesmethods to columns with type converters. They can be used to compare the column against a list of Dart expressions that will be mapped through a type converter. - Add
TableStatements.insertAllto atomically insert multiple rows. - Add
singleClientModetoremote()andDriftIsolateconnections to make the common case with one client more efficient. - Fix a concurrency issue around transactions.
- Add
NativeDatabase.createInBackgroundas a drop-in replacement forNativeDatabase. It creates a drift isolate behind the scenes, avoiding all of the boilerplate usually involved with drift isolates. - Experimental: Add a modular generation mode in which drift will generate multiple smaller files instead of one very large one with all tables and generated queries.
2.2.0 #
- Always escape column names, avoiding the costs of using a regular expression to check whether they need to be escaped.
- Add extensions for binary methods on integer expressions:
operator ~,bitwiseAndandbitwiseOr.
2.1.0 #
- Improve stack traces when using
watchSingle()with a stream emitting a non- singleton list at some point. - Add
OrderingTerm.nullsto control theNULLS FIRSTorNULLS LASTclause in Dart.
2.0.2+1 #
- Revert the breaking change around
QueryRow.readonly returning non-nullable values now - it was causing issues with type inference in some cases.
2.0.1 #
- Fix an error when inserting a null value into a nullable column defined with additional checks in Dart.
2.0.0 #
💡: More information on how to migrate is available in the documentation.
- Breaking: Type converters now return the types that they were defined to return (instead of the nullable variant of those types like before). It is an error to use a non-nullable type converter on a column that is nullable in SQL and vice-versa.
- Breaking: Mapping methods on type converters are now called
toSqlandfromSql. - Breaking: Removed
SqlTypeSystemand subtypes ofSqlType:- To describe the type a column has, use the
DriftSqlTypeenum - To map a value from Dart to SQL and vice-versa, use an instance of
SqlTypes, reachable viadatabase.options.types.
- To describe the type a column has, use the
- Breaking:
Expressions (includingColumns) always have a non-nullable type parameter now. They are implicitly nullable, soTypedResult.readnow returns a nullable value. - Breaking:
QueryRow.readcan only read non-nullable values now. To read nullable values, usereadNullable. - Breaking: Remove the
includeJoinedTableColumnsparameter onselectOnly(). The method now behaves as if that parameter was turned off. To use columns from a joined table, add them withaddColumns. - Breaking: Remove the
fromDatafactory on generated data classes. Use themapmethod on tables instead. - Add support for storing date times as (ISO-8601) strings. For details on how to use this, see the documentation.
- Consistently handle transaction errors like a failing
BEGINorCOMMITacross database implementations. - Add
writeReturningto update statements;deleteReturningandgoAndReturnto delete statatements. - Support nested transactions.
- Support custom collations in the query builder API.
- Custom row classes can now be constructed with static methods too. These static factories can also be asynchronous.
1.7.0 #
- Add the
int64()column builder to store large integers. These integers are still stored as 64-bit ints in the database, but represented as aBigIntin Dart. This enables better web support for integers larger than 2^52. More details are in the documentation. - Add
filteranddistinctsupport togroupConcat. - Fix a deadlock with the
sqflite-based implementation if the first operation in atransactionis a future backed by a query stream.
1.6.0 #
- Add the
unique()method to columns and theuniqueKeysoverride for tables to define unique constraints in Dart tables. - Add the
check()method to the Dart column builder to generateCHECKcolumn constraints. - Also apply type converters for json serialization and deserialization if they
mix in
JsonTypeConverter. - Add the very experimental
package:drift/wasm.dartlibrary. It uses WebAssembly to access sqlite3 without any external JavaScript libraries, but requires you to add a WebAssembly module to theweb/folder. Please note that this specific library is not subject to semantic versioning until it leaves its experimental state. It also isn't suitable for production use at the moment. - Internally use
package:jsto wrap sql.js.
1.5.0 #
- Add
DataClassName.extendingto control the superclass of generated row classes. - Add
setupparameter to the constructors ofWebDatabasetoo. - Don't write variables for expressions in
CREATE VIEWstatements. - Improve stack traces for errors on a remote isolate.
- Add
MultiExecutor.withReadPoolconstructor to load-balance between multiple reading executors. This can be used in a multi-isolate approach if some queries are expensive.
1.4.0 #
- Most methods to compose statements are now available as an extension on
tables. As an alternative to
update(todos).replace(newEntry), you can now writetodos.replaceOne(newEntry). - Deprecate the
from(table)API introduced in 1.3.0. Having the methods on the table instances turned out to be even easier! - In drift files, you can now use
LIST(SELECT ...)as a result column to get all results of the inner select as aListin the result set.
1.3.0 #
- Add the
from(table)method to generated databases. It can be used to write common queries more concisely. - Make
groupConcatnullable in the Dart API. - Throw an exception in a
NativeDatabasewhen multiple statements are run in a single call. In previous versions, parts of the SQL string would otherwise be ignored. - Close the underlying database when a drift isolate is shut down.
1.2.0 #
- Properly support stream update queries on views.
- Reading blobs from the database is more lenient now.
- Provide a stack trace when
getSingle()orwatchSingle()is used on a query emitting more than one row.
1.1.1 #
- Rollback transactions when a commit fails.
- Revert a change from 1.1.0 to stop serializing messages over isolates.
Instead, please set the
serializeparameter tofalseon theDriftIsolatemethods.
1.1.0 #
- Add the
referencesmethod toBuildColumnto reference a column declared in another Dart table. - Add the
generateInsertableoption to@UseRowClass. When enabled, the generator will emit an extension to use the row class as anInsertable. Thanks to @westito. - Allow the generator to emit correct SQL code when using arrays with the
new_sql_code_generationoption in specific scenarios. - Add support for strict tables in
.driftfiles. - Add the
generatedAsmethod to declare generated columns for Dart tables. - Add
OrderingTerm.randomto fetch rows in a random order. - Improved support for pausing query stream subscriptions. Instead of buffering events, query streams will suspend fetching data if all listeners are paused.
- Drift isolates no longer serialize messages into a primitive format. This will reduce the overhead of using isolates with Drift.



