Releases: simolus3/drift
Drift 2.22.0
Core drift package:
- Add
sqliteAny()
method to tables to declareANY
columns. - Add missing parentheses around adjacent expressions of the same precedence.
- Fix creating tables that are both
STRICT
andWITHOUT ROWID
. - WASM: Report worker failures to make them easier to diagnose.
- Allow closing stream queries synchronously, making drift easier to use in widget tests.
Generator improvements
- Add support for the
dbstat
module. - Prioritize null propagation in type resolver, leading to more accurate analysis on which columns are nullable.
- CLI options dealing with schemas now support views defined in Dart (#3285).
- Pass language version to dart formatter when generating code.
- Deprecate
package:drift_dev/api/migrations.dart
in favor ofpackage:drift_dev/api/migrations_native.dart
. - Support runtime schema verification on the web.
- Fix generated code missing question marks for nullable types in some instances.
- Add (opt-in)
row_class_constructor_all_required
builder option. - Support the
dbstat
table in drift-file queries when enabling thedbstat
module. - Fix
make-migrations
using invalid import URIs in generated test on Windows.
drift_flutter 0.2.2
- Fix infinite loop in isolate server lookups when using
shareAcrossIsolates
across hot restarts.
Drift 2.21.0
Versions 2.21.0 of drift
and drift_dev
as well as version 0.2.1 of drift_flutter
have just been released:
Core changes
View.from
is now declared to return aJoinedSelectStatement
, the type it returns at runtime.- The manager APIs now support computed fields, allowing advanced SQL expressions to be embedded into simple manager queries.
Isolate improvements
- To infer whether serialization is required for inter-isolate communication, drift now sends a test message instead of serializing by default.
drift_flutter
: Enable serialization between background isolates where necessary.
Tooling and generator
- The DevTools extension can now clear drift databases.
- Fix Dart-defined
check
constraints not being considered in exported schemas. - Columns can now be defined with
late final
fields. Defining columns with getters=>
is still supported too.class MyTable extends Table { // Before: IntColumn get id => integer().autoIncrement()(); // After: late final id = integer().nullable()(); }
- Make
build.yaml
definitions passbuild_runner doctor
. - Fix
generate_manager
option not consistently being applied to modular builds. - Add the
make-migrations
command which combines the existing schema commands into a single tool.
Drift 2.20.3
This patch release fixes a deadlock that could occur when using concurrent nested transactions, a problem introduced in the 2.20.0 release (#3244). Note that drift_worker.js
bundles from drift version 2.20.0 until 2.20.2 also have the issue and need to be updated to apply the fix.
Drift 2.20.1
This patch release fixes the following issues:
Core drift package
- Migrate legacy
package:drift/web.dart
to the new JS interop SDK libraries. For backwards compatibility, thechannel()
extension on theMessagePort
class indart:html
has been kept.
Oncedart:html
is removed from the Dart SDK, that extension will have to be removed from drift as well. - Fix cast errors in the protocol for remote workers when compiling with
dart2wasm
. - Introduce a faster protocol for communicating with workers. This protocol is enabled automatically after upgrading
drift_worker.js
.
Generator
- Strip leading numbers when generating modular accessor names for drift files, fixing syntax errors.
- Support triggers targeting views.
- Include dialect-specific constraints in exported schema files.
- Fix
schema export
not respecting column constraints of the target dialect. - Resolve
json_extract
return types from context if possible.
Drift 2.20.0
Drift changes
- Add
readPool
parameter toNativeDatabase
. It will spawn an additional pool of isolates used to serve multiple reads in parallel, which can improve performance in some specific workloads. - Mark legacy
package:drift/web.dart
as deprecated. Users should migrate topackage:drift/wasm.dart
.
drift_dev changes
- Improve manager API to be able to resolve references when running queries.
- Add
TableIndex.sql
, allowing database indexes to be defined in SQL without using drift files. - Add
DataClassName.implementing
, which can be used to make drift-generated row classes implement existing interfaces.
drift_flutter changes
- Add
DriftNativeOptions
withshareAcrossIsolates
option that will give multiple isolates access to the same drift database without having to manually set up ports.
Drift 2.19.1
This patch release fixes exclusively
not working on the web (#3089). The fix requires a drift_worker.js
update.
Drift 2.19.0
Drift 2.19.0 expands the migrator API and adds a method to exclusively use the database without a transaction (useful for things like setting pragmas which are unsupported in transactions).
- Add
exclusively
method to database classes, allowing a block to temporarily take exclusive control over a database connection without starting a transaction. - Add the
enableMigrations
parameter toWasmDatabase
to control whether drift migrations are enabled on that database. - Add
initiallyDeferred
option toreferences()
column builder for foreign key constraints. - Add
dropColumn
method toMigrator
. - Add
selectExpressions
method to build select statements without aFROM
clause. - Both
transaction
andexclusively
will wait for the transaction or the exclusive lock to be set up before invoking their callback now. - In drift files: Support for sqlite 3.46.0.
This release also fixes the following bugs:
- Fix encoding
BigInt
arguments in batched statements sent to web workers. Note that the fix also requires the latestdrift_worker.js
to be effective. - Fix stream queries possibly cancelling a migration if they are the first method on the database.
- Drift files: Make columns coming from subquery expressions nullable.
- Fix generated
CREATE VIEW
statements containing existing row class syntax only supposed to be used during static analysis. - Fix Dart views referencing the same column from different table aliases using columns with the same name.
- Fix
drift_dev schema steps
generating invalid code when no migrations have been defined yet. - Fix generated imports for extension member references in modular mode.
While not part of the core packages in this repository, another addition is drift_hrana, which allows using drift with a libsql server - that may be useful for some Dart backends using Turso or related offerings.
Drift 2.18.0
Manager APIs
The biggest new feature in this release is the addition of manager APIs, which make it much easier to write common simple queries. The new API has been designed to be easier to use and to avoid boilerplate for common CRUD queries. This feature requires additional code to be generated - if you prefer using the existing APIs exclusively, you can use the generate_manager: false
builder option.
Other additions
- Drift now supports geopoly tables and queries in
.drift
files if the extension is enabled. - Add
AggregateFunctionExpression
to write custom aggregate function invocations in the Dart query builder. - The
json_group_array
andjsonb_group_array
functions now contain anorderBy
andfilter
parameter.
Fixes
- Improve finding the correct import alias in generated code for part files.
Drift 2.17.0
Core
- Add the
TypeConverter.extensionType
factory to create type converters for extension types. - Fix invalid SQL syntax being generated for
BLOB
literals on postgres. - Add a
setup
parameter toSchemaVerifier
. It is called when the verifier creates database connections (similar to the callback onNativeDatabase
) and can be used to register custom functions.
Generator
- Adds
companion
entry toDataClassName
to override the name of the generated companion class. - Fix drift using the wrong import alias in generated part files.
- Add the
use_sql_column_name_as_json_key
builder option. - Fix parsing binary literals in drift files.
- Expand support for
IN
expressions in drift files, they now support tuples on the left-hand side and the shorthand syntax for table references and table-valued functions. - Allow custom class names for
CREATE VIEW
statements. - Support the
INT64
hint forCREATE TABLE
statements.
Drift 2.16.0
Drift 2.16.0 mostly contains performance and stability improvements:
- When a migration throws, the database will now block subsequent operations instead of potentially allowing them to operate on a database in an inconsistent state.
- Improve stack traces for errors happening on drift isolates (which includes usages of
NativeDatabase.createInBackground
). - Statements built through the Dart query builder will now run in the context active while they are running, instead of the context active at the time they were created. For instance, creating an
UpdateStatement
withdatabase.update
outside of a transaction and then callingUpdateStatement.write
inside of a transaction will now perform the update inside of the transaction, instead of causing a deadlock. - Improve performance when reading results from joined statements with many rows.
- Don't cache
EXPLAIN
statements, avoiding schema locks. - Deprecate
Value.ofNullable
in favor ofValue.absentIfNull
, which is more explicit about its behavior and allows nullable types too. - Migrate
WasmDatabase
todart:js_interop
andpackage:web
.
Improvements to the generator
- Allow selecting from virtual tables using the table-valued function syntax.
- Keep import alias when referencing existing elements in generated code (#2845).
Improvements to drift_postgres
- Drift's comparable expression operators are now available for expressions using postgres-specific
date
ortimestamp
types.