Skip to content

Releases: simolus3/drift

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.

Drift 2.14

04 Dec 10:38
drift-2.14.0
633cc52
Compare
Choose a tag to compare

New features in drift:

  • Add the QueryInterceptor API to easily monitor or transform all database calls made by drift.
  • Add the count() extension on tables to easily count rows in tables or views.
  • For updates made in drift files, we now support the column-name-list syntax.

Changes to the generator:

  • Breaking change: The name of the generated row class derived from the name of the Dart table name now supports more forms of plurals. For instance, a table without a @DataClassName annotation named Categories would now generate a Category class instead of Categorie. This is done in a minor release because we assume users previously running into this are already using @DataClassName as a workaround.
  • Make versioned schema snapshots generated by drift_dev schema steps public.
  • Don't generate const row classes when they are extending a class which isn't const.
  • Fix indices attached to tables not generating reliably.

Drift 2.13

20 Oct 10:18
drift-2.13.0
c854f22
Compare
Choose a tag to compare

Core Library

  • Add support for custom types, which are useful when extending drift to support other database engines.
  • Add Expression.and and Expression.or to create disjunctions and conjunctions of sub-predicates.
  • Step-by-step migrations now save the intermediate schema version after each step.
  • The TypeConverter.json factory reduces the boilerplate needed to define type converters doing JSON conversions.

Backends

  • Add APIs to setup Wasm databases with custom drift workers.
  • The drift_postgres package is now available on pub.dev.

Utilities

  • Drift now provides a DevTools extension embedding the drift inspector written by Koen Van Looveren. When opening DevTools from Flutter's beta channel, a Drift tab is available to inspect open databases.

Drift 2.12.1

27 Sep 16:22
drift-2.12.1
b5bc646
Compare
Choose a tag to compare

This minor release fixes the following issues:

  • Fix readWithConverter throwing an exception for null values in non-nullable columns (#2640).
  • Fix * columns in analyzed SQL queries expanding to more columns than what would be correct (#2641).
  • Fix invalid types listed in views crashing the generator (#2636).
  • Fix a generator crash when seeing an index referencing expressions instead of columns (#2643).

Drift 2.12.0

24 Sep 18:46
drift-2.12.0
8d05c9e
Compare
Choose a tag to compare

This drift release adds support for defining a database index in Dart and improves JSON support.

Full list of changes:

  • Add support for table-valued functions in the Dart query builder.
  • Support the json_each and json_tree table-valued functions.
  • Add the @TableIndex annotation for table classes to add an index to the table.
  • Add the TypeConverter.json method to define type converters storing JSON values more easily.
  • Add TypedResult.readWithConverter to read a column with a type converter from a join result row.

Drift 2.11.1

27 Aug 15:39
drift-2.11.1
303d738
Compare
Choose a tag to compare

This minor drift release contains bug fixes and performance improvements for the builder:

  • Allow references to sqlite_schema in drift files.
  • Support the timediff and octet_length functions from sqlite 3.43.0.
  • Reduce the amount of assets read by drift, improving build performance and enabling faster incremental rebuilds.
  • Fix missing import references around @UseRowClass with generateInsertable: true when modular code generation is enabled.
  • 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.

Drift 2.11.0

11 Aug 13:59
drift-2.11.0
f857cb1
Compare
Choose a tag to compare

This release adds new features to the Dart query builder API:

  • Add support for subqueries in the Dart query builder.
  • Add isInExp and isNotInExp to construct IS IN expressions with arbitrary expressions.
  • Add the substr extension on Expression<String> to call the sqlite3 function from the Dart API.

Other new additions to drift:

  • Add isolateSetup to NativeDatabase.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.

drift_dev has also seen some optimizations in how it generates query code, which enables new features:

  • Nested result columns in drift files can now refer to any result set (e.g. a table-valued function or a subquery). They were restricted to direct table references before.
  • Add the dialects builder option to generate code supporting multiple SQL dialects.
  • Add the preamble option for non-shared or modular build setups to mirror the preamble option from source_gen:combining_builder.