drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.

MIT License

Stars
2.5K
Committers
141
drift - Drift 2.4.0

Published by simolus3 almost 2 years ago

This drift release extends support for existing row classes to queries, allows storing enums by their name and handles ANY columns. A full list of improvements and new features:

New features

  • Support existing row types on queries defined in drift files.
  • Enums can now be stored by their name instead of their index - use the textEnum() column in Dart or the ENUMNAME column type in .drift files.
  • Add the DriftAny type to handle arbitrary SQL values. It will be used by the generator for columns types declared as ANY in strict tables.
  • drift_dev schema dump can now dump the schema of existing sqlite3 database files as well.
  • Adds the case_from_dart_to_sql option with the possible values: preserve, camelCase, CONSTANT_CASE, snake_case, PascalCase, lowercase and UPPERCASE (default: snake_case).
  • Add updates parameter to Batch.customStatement - it can be used to specify which tables are affected by the custom statement.
  • Add likeExp to generate LIKE expressions with any comparison expression.

Notable improvements

  • Fix UNIQUE keys declared in drift files being written twice.
  • 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.alterTable not to work if a view references the altered table.
  • Warn about suspicious int or text literals being inserted into enum columns.
  • For Dart-defined columns, customConstraints are now parsed and respected by the generator.
  • It is now allowed to interleave queries and tables in a drift file.

This drift release also adds experimental support for record types as existing types for tables or queries. Note that records are experimental in the Dart language, so the feature may be updated or removed depending on its development in the language.

drift - Drift 2.3.0

Published by simolus3 almost 2 years ago

  • Add the JsonTypeConverter2 mixin. It behaves similar to the existing json type converters, but can use a different SQL and JSON type.
  • Add isInValues and isNotInValues methods 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.insertAll to atomically insert multiple rows.
  • Add singleClientMode to remote() and DriftIsolate connections to make the common case with one client more efficient.
  • Fix a concurrency issue around transactions.
  • Add NativeDatabase.createInBackground as a drop-in replacement for NativeDatabase(). 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.
drift - Drift 2.2.0

Published by simolus3 about 2 years ago

  • Potentially breaking bug-fix: Fix the nullability of columns generated for Dart-defined views. See the documentation for details.
  • 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 ~, bitwiseAnd and bitwiseOr.
  • Serialize uniqueKeys overrides into a database schema, allowing them to be properly tested in schema tests.
  • Support the latest version of the analyzer package.
drift - Drift 2.1.0

Published by simolus3 about 2 years ago

Changes in drift version 2.1.0:

  • Improve stack traces when using watchSingle() with a stream emitting a non-singleton list at some point.
  • Add OrderingTerm.nulls to control the NULLS FIRST or NULLS LAST clause in Dart.

Changes in drift_dev version 2.1.0 and sqlparser version 0.23.2:

  • Analysis support for fts5 tables with external content tables.
  • Analysis support for the rtree module.
  • Internally prepare for an upcoming breaking analyzer change around how classes are mapped to elements.
  • Improve static analysis around subqueries in SQL.
drift - Drift 2.0.2

Published by simolus3 about 2 years ago

This patch release fixes some issues introduced by the upgrade to drift 2.0:

  • drift 2.0.2: Revert the breaking change around QueryRow.read only returning non-nullable values now - it was causing issues with type inference in some cases.
  • drift_dev 2.0.2: Generate typedefs for the signatures of scoped_dart_components, making it easier to re-use them in your own methods.
  • sqlparser 0.23.1: Gracefully handle tokenizer errors related to @ or $ variables instead of crashing.
drift - Drift 2.0.0

Published by simolus3 about 2 years ago

The first major update to the drift packages contains a number of breaking changes and removes some obsolete features. This includes:

  • 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 toSql and fromSql.
  • Breaking: Removed SqlTypeSystem and subtypes of SqlType:
    • To describe the type a column has, use the DriftSqlType enum
    • To map a value from Dart to SQL and vice-versa, use an instance of SqlTypes, reachable via database.options.types.
  • Breaking: Expressions (including Columns) always have a non-nullable type parameter now. They are implicitly nullable, so TypedResult.read now returns a nullable value.
  • Breaking: QueryRow.read can only read non-nullable values now. To read nullable values, use readNullable.
  • Breaking: Remove the includeJoinedTableColumns parameter on selectOnly(). The method now behaves as if that parameter was turned off. To use columns from a joined table, add them with addColumns.
  • Breaking: Remove the fromData factory on generated data classes. Use the map method 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 BEGIN or COMMIT across database implementations.
  • Add writeReturning to update statements; deleteReturning and goAndReturn to 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.

💡: More information on how to migrate is available in the documentation.

drift - `drift_dev` 1.7.1

Published by simolus3 about 2 years ago

This small update to drift_dev supports the latest version of the analyzer_plugin package and removes usages of deprecated analyzer APIs.

drift - Drift 1.7.1

Published by simolus3 over 2 years ago

This minor release fixes a bug where the NativedDatabase implementation would not dispose statements if running them threw an exception (https://github.com/simolus3/drift/issues/1917).

drift - Drift 1.7.0

Published by simolus3 over 2 years ago

This drift release brings the following new features and improvements:

  • Add the int64() column builder to store large integers. These integers are still stored as 64-bit ints in the database, but represented as a BigInt in Dart. This enables better web support for integers larger than 2⁵². More details are in the documentation.
  • Add filter and distinct support to groupConcat.
  • Fix a deadlock with the sqflite-based implementation if the first operation in a transaction is a future backed by a query stream.
  • Support version 4.x of the analyzer package

This release also uses version 0.22.0 of the sqlparser package with the following changes:

  • A new resolver for tables and columns in analyzed queries. If this breaks anything for you, please open an issue!
  • Lint for DISTINCT misuse in aggregate function calls.
  • Analysis support for new features in the upcoming sqlite 3.39 (RIGHT and FULL joins, IS (NOT) DISTINCT FROM expressions)
  • Fix type inference for SUM() calls around int "subtypes" like booleans.
drift - Drift 1.6.0

Published by simolus3 over 2 years ago

  • Add the unique() method to columns and the uniqueKeys override to define unique constraints in Dart tables.
  • Add the check() method to the Dart column builder to generate CHECK column constraints.
  • Also apply type converters for json serialization and deserialization if they mix in JsonTypeConverter.
  • Add the very experimental package:drift/wasm.dart library. It uses WebAssembly to access sqlite3 without any external JavaScript libraries, but requires you to add a WebAssembly module to the web/ 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:js to wrap sql.js.
drift - Drift 1.5.0

Published by simolus3 over 2 years ago

  • Add DataClassName.extending to control the superclass of generated row classes.
  • Add setup parameter to the constructors of WebDatabase too.
  • Don't write variables for expressions in CREATE VIEW statements.
  • Improve stack traces for errors on a remote isolate.
  • Add MultiExecutor.withReadPool constructor to load-balance between multiple reading executors. This can be used in a multi-isolate approach if some queries are expensive.

drift_dev also has new features:

  • Add validateDatabaseSchema extension to package:drift_dev/api/migrations.dart. It validates that the schema of a database at runtime matches what one would expect. This can be used to test the correctness of migrations at runtime without special testing code.
  • New features in sqlite 3.38 are supported in analyzed queries and drift files when changing the dialect version in the build options.
drift - Drift 1.4.0

Published by simolus3 over 2 years ago

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 write todos.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 a List in the result set.
drift - Drift 1.3.0

Published by simolus3 almost 3 years ago

  • Add the from(table) method to generated databases. It can be used to write common queries more concisely.
  • Make groupConcat nullable in the Dart API.
  • Throw an exception in a NativeDatabase when 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.
drift - drift_dev 1.2.1

Published by simolus3 almost 3 years ago

  • Support the latest versions of analyzer and analyzer_plugin.
drift - Drift 1.2.0

Published by simolus3 almost 3 years ago

This minor release implements changes in the generated code necessary to support streams from views in the Dart API.

Additionally,

  • Reading blobs from the database is more lenient now.
  • watchSingle() and watchSingleOrNull() now throws an error with a stack trace when used on a query emitting multiple rows.
  • With sqlparser 0.19.1, group_concat was made nullable as evaluates to NULL for empty groups.
drift - Drift 1.1.1

Published by simolus3 almost 3 years ago

This patch release contains the following changes:

  • Rollback transactions when a commit fails.
  • Revert a change from 1.1.0 to stop serializing messages over isolates. Instead, please set the serialize parameter to false on the DriftIsolate methods.

The generator, released as drift_dev version 1.1.1 contains a fix related to custom row classes with generateInsertable: true.

drift - Drift 1.1.0

Published by simolus3 almost 3 years ago

This release consists of drift version 1.1.0, drift_dev version 1.1.0 and sqlparser version 0.19.0:

  • Add the references method to BuildColumn to reference a column declared in another Dart table.
  • Add the generateInsertable option to @UseRowClass. When enabled, the generator will emit an extension to use the row class as an Insertable.
  • Allow the generator to emit correct SQL code when using arrays with the new_sql_code_generation option in specific scenarios.
  • Add support for strict tables in .drift files.
  • Add the generatedAs method to declare generated columns for Dart tables.
  • Add OrderingTerm.random to 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.
  • Initial support for STRICT tables defined in .drift files.
  • Support for generated columns for tables defined in .drift files.

Big thanks to everyone who contributed to this release!

drift - sqlparser-0.18.1

Published by simolus3 almost 3 years ago

This hotfix release fixes a bug when comparing AST nodes with a different amount of children (#1575). The broken comparison may have caused false-positives in migration tests.

drift - Drift-dev 1.0.2

Published by simolus3 about 3 years ago

With this release, running moor_generator migrate will also rewrite usages of the moor plugin in an analysis_options.yaml file.

drift - Drift 1.0.1, Moor 4.6.0

Published by simolus3 about 3 years ago

  • Add DoUpdate.withExcluded to refer to the excluded row in an upsert clause.
  • Add optional where clause to DoUpdate constructors

Please note

With this release, moor has been renamed to drift. No immediate action is necessary, the moor package will continue to work until the next breaking release. The functionality of moor 4.6.0 is identical to drift 1.0.1.

An automatic migration tool can help you make the switch from moor to drift in minutes. See the documentation for all the details. Thanks!

Package Rankings
Top 1.13% on Pub.dev
Badges
Extracted from project README
Build Status Using melos Main version Generator version sqlparser
Related Projects