Skip to content

Releases: simolus3/drift

Drift 2.20.3

29 Sep 12:09
drift-2.20.3
f38c539
Compare
Choose a tag to compare

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

08 Sep 13:17
drift-2.20.1
74af262
Compare
Choose a tag to compare

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, the channel() extension on the MessagePort class in dart:html has been kept.
    Once dart: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

16 Aug 09:09
drift-2.20.0
c49bd49
Compare
Choose a tag to compare

Drift changes

  • Add readPool parameter to NativeDatabase. 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 to package: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 with shareAcrossIsolates option that will give multiple isolates access to the same drift database without having to manually set up ports.

Drift 2.19.1

12 Jul 11:03
drift-2.19.1
7b2168c
Compare
Choose a tag to compare

This patch release fixes exclusively not working on the web (#3089). The fix requires a drift_worker.js update.

Drift 2.19.0

11 Jul 11:40
drift-2.19.0
2e343a5
Compare
Choose a tag to compare

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 to WasmDatabase to control whether drift migrations are enabled on that database.
  • Add initiallyDeferred option to references() column builder for foreign key constraints.
  • Add dropColumn method to Migrator.
  • Add selectExpressions method to build select statements without a FROM clause.
  • Both transaction and exclusively 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 latest drift_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

04 May 22:19
drift-2.18.0
7d1430c
Compare
Choose a tag to compare

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 and jsonb_group_array functions now contain an orderBy and filter parameter.

Fixes

  • Improve finding the correct import alias in generated code for part files.

Drift 2.17.0

20 Apr 13:56
drift-2.17.0
9bcaedd
Compare
Choose a tag to compare

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 to SchemaVerifier. It is called when the verifier creates database connections (similar to the callback on NativeDatabase) and can be used to register custom functions.

Generator

  • Adds companion entry to DataClassName 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 for CREATE TABLE statements.

Drift 2.16.0

24 Feb 22:45
drift-2.16.0
417c2c1
Compare
Choose a tag to compare

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 with database.update outside of a transaction and then calling UpdateStatement.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 of Value.absentIfNull, which is more explicit about its behavior and allows nullable types too.
  • Migrate WasmDatabase to dart:js_interop and package: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 or timestamp types.

Drift 2.15.0

17 Jan 23:01
drift-2.15.0
38d603c
Compare
Choose a tag to compare

Drift 2.15 introduces new features improving web support and for sharing database classes against different databases (e.g. sqlite3 and Postgres):

  • Better support for custom SQL types:
    • Custom types are now applied consistently in the query builder API.
    • Add DialectAwareSqlType, a custom type depending on the runtime dialect. This allows writing "polyfill" types that use native date types on Postgres while falling back to a textual representation on sqlite3 for instance.
  • Initial JSONB support: sqlite 3.45 supports a binary JSON format aiming at reducing size and improving performance for JSON operations in SQL. Drift 2.15.0 supports jsonb functions in the query builder through package:drift/extensions/json1.dart. jsonb functions are also supported by sqlparser when analyzing drift files.
  • Runtime improvements:
    • Wasm databases hosted in workers are closed after the last client disconnects.
    • Add enableMigrations parameter to NativeDatabase to disable migrations, a flag useful for existing databases managed with an external schema tool.
  • Add analysis errors for illegal unqualified references to old and new in CREATE TRIGGER statements.

This release fixes a bug in the generator that is potentially breaking: Tables defined in .drift files with a NULL column constraint (e.g. CREATE TABLE users (display_name TEXT NULL, ...)) were not generated correctly - the NULL constraint was absent from the generated schema. This is not a soundness issue since NULL constraints are the default and ignored by sqlite3. However, it means that the actual schema of databases deviates from what drift will now expect, since NULL constraints will be expected from drift 2.15. This can cause issues with the schema validator after upgrading. If you are affected by this problem, the two possible ways to fix this are:

  1. To remove NULL constraints from column declarations in drift files. You don't need a migration for this since they don't affect semantics.
  2. To keep NULL constraints. In this case, you'll have to increment the schema version of your database and use Migrator.alterTable(affectedTable) on all affected tables to make it consistent with the schema with NULL constraints that drift is now expecting.

Also note that this only applies to drift files and not to NOT NULL constraints, which have always been generated correctly. Finally, older snapshots generated with drift_dev schema generate will continue to not report the NULL constraint, meaning that older migration tests won't break due to this change. If you have any questions or concerns about this, please reach out by opening an issue.

Drift 2.14.1

12 Dec 11:28
drift-2.14.1
7964782
Compare
Choose a tag to compare

This minor release fixes bugs in the drift and the drift_dev packages:

  • Fix WasmProbeResult.open ignoring the ìnitializeDatabase callback.
  • Fix inconsistencies when generating Variable instances for columns with custom types.
  • Fix a build performance regression introduced in version 2.14.0 related to analyzing imports in drift files.