2021-10-13 13:08:38 -07:00
|
|
|
## 4.6.1
|
2021-10-12 08:36:10 -07:00
|
|
|
|
2021-10-13 13:08:38 -07:00
|
|
|
- Fix the moor analyzer plugin not starting
|
2021-10-12 08:36:10 -07:00
|
|
|
|
2021-10-31 07:16:14 -07:00
|
|
|
Version 4.6.1+1 adds information about the name change to the README.
|
|
|
|
|
2021-10-11 06:55:01 -07:00
|
|
|
## 4.6.0
|
2021-09-22 08:08:37 -07:00
|
|
|
|
|
|
|
- Add `DoUpdate.withExcluded` to refer to the excluded row in an upsert clause.
|
2021-10-05 09:48:35 -07:00
|
|
|
- Add optional `where` clause to `DoUpdate` constructors
|
2021-09-22 08:08:37 -07:00
|
|
|
|
2021-10-07 12:06:18 -07:00
|
|
|
### Important notice
|
|
|
|
|
|
|
|
Moor has been renamed to `drift`. This package will continue to be supported until the next major release (5.0.0),
|
2021-10-11 06:55:01 -07:00
|
|
|
no immediate action is needed.
|
2021-10-09 12:43:30 -07:00
|
|
|
|
|
|
|
At the next breaking release, moor will be discontinued in favor of the `drift` package.
|
|
|
|
Please consider migrating to `drift` at a suitable opportunity.
|
|
|
|
Automated migration tooling exists! See https://drift.simonbinder.eu/name for details.
|
2021-10-07 12:06:18 -07:00
|
|
|
|
2021-08-20 09:58:15 -07:00
|
|
|
## 4.5.0
|
2021-07-30 06:32:40 -07:00
|
|
|
|
|
|
|
- Add `moorRuntimeOptions.debugPrint` option to control which `print` method is used by moor.
|
2021-08-06 07:47:34 -07:00
|
|
|
- Add a `rowId` extension on generated tables.
|
2021-07-30 06:32:40 -07:00
|
|
|
- Add `NullAwareTypeConverter` to simplify type converters that always map `null` from and to `null`.
|
2021-08-10 07:52:18 -07:00
|
|
|
- Kill backing isolates after calling `MoorIsolate.shutdownAll`.
|
2021-07-30 06:32:40 -07:00
|
|
|
|
2021-07-08 05:44:41 -07:00
|
|
|
## 4.4.1
|
|
|
|
|
|
|
|
- Include latest generator in analyzer plugin
|
|
|
|
|
2021-07-03 04:36:43 -07:00
|
|
|
## 4.4.0
|
2021-05-20 02:15:28 -07:00
|
|
|
|
2021-07-03 04:36:43 -07:00
|
|
|
- Add `Value.ofNullable` constructor to easily wrap nullable values.
|
2021-06-01 13:05:12 -07:00
|
|
|
- Support selecting views declared in a moor file in Dart (with `select`,
|
|
|
|
`join` and similar methods)
|
2021-06-04 09:43:45 -07:00
|
|
|
- Add the `scoped_dart_components` builder option to generate a function for
|
|
|
|
[Dart components in SQL](https://moor.simonbinder.eu/docs/using-sql/moor_files/#dart-components-in-sql).
|
|
|
|
The function's parameters reflect tables that are in scope.
|
2021-06-30 13:30:56 -07:00
|
|
|
- Add the `UpsertMultiple` class to run multiple upsert clauses in an insert.
|
|
|
|
This requires sqlite3 version 3.35 or later.
|
2021-06-08 08:23:18 -07:00
|
|
|
- Add the `closeUnderlyingOnClose` argument to `VmDatabase.opened` as an option
|
|
|
|
to keep the underlying instance opened when closing the `VmDatabase`.
|
2021-06-13 12:34:39 -07:00
|
|
|
- The `tableUpdates` stream now emits the relevant updates instead of `null`.
|
2021-07-03 04:36:43 -07:00
|
|
|
- Reflect type converters in generated columns. The `equalsValue` method can be used
|
|
|
|
as an equals with a value mapped by a type converter.
|
|
|
|
- Improve nullability analysis for SQL queries.
|
|
|
|
- __Note__: You have to re-generate sources with `moor_generator` version 4.4.0 after
|
|
|
|
upgrading to this version. Apologies for the inconvenience.
|
2021-06-08 08:23:18 -07:00
|
|
|
|
2021-05-28 13:05:34 -07:00
|
|
|
## 4.3.2
|
|
|
|
|
|
|
|
- Fix `insertReturning` not updating streams
|
|
|
|
- Fix streams emitting stale data if a new subscriber attaches immediately
|
|
|
|
after an update.
|
|
|
|
|
2021-05-24 03:52:42 -07:00
|
|
|
## 4.3.1
|
|
|
|
|
|
|
|
- Fix encoding table updates without a kind over isolates
|
|
|
|
- Fix deserializing some nullable types in the default value serializer
|
|
|
|
|
2021-05-15 08:23:29 -07:00
|
|
|
## 4.3.0
|
2021-04-04 12:37:32 -07:00
|
|
|
|
2021-04-09 14:35:58 -07:00
|
|
|
- Support custom, existing classes for rows! See the `@UseRowClass` annotation
|
2021-04-10 04:01:24 -07:00
|
|
|
for details.
|
2021-04-04 12:37:32 -07:00
|
|
|
- Add `CASE WHEN` expressions with the `caseMatch` method on `Expression`
|
2021-05-06 09:19:01 -07:00
|
|
|
- Add `insertReturning` which returns the generated row after an insert
|
2021-05-07 04:45:46 -07:00
|
|
|
- Add `min`, `max` and `avg` functions for `DateTime` expressions
|
2021-04-19 12:39:10 -07:00
|
|
|
- On supported platforms, cancel pending stream selects when the stream is disposed
|
|
|
|
- `moor_flutter` is supported
|
|
|
|
- `moor/ffi` is supported when used on a background isolate
|
2021-04-04 12:37:32 -07:00
|
|
|
|
2021-03-23 08:59:11 -07:00
|
|
|
## 4.2.1
|
|
|
|
|
|
|
|
- Deprecate `readBool`, `readString`, `readInt`, `readDouble`, `readDateTime`
|
|
|
|
and `readBlob` in `QueryRow`.
|
|
|
|
Use `read` directly (which supports nullable types).
|
|
|
|
|
2021-03-10 01:38:25 -08:00
|
|
|
## 4.2.0
|
|
|
|
|
2021-03-13 01:41:36 -08:00
|
|
|
- Fixed subqueries not affecting stream updates
|
2021-03-18 08:58:12 -07:00
|
|
|
- Throw a `CouldNotRollBackException` when rolling back a transaction throws
|
2021-03-10 01:38:25 -08:00
|
|
|
|
2021-02-20 13:03:34 -08:00
|
|
|
## 4.1.0
|
2021-01-20 03:06:48 -08:00
|
|
|
|
|
|
|
- Reverted the `SelectableUtils` extension, its members have been added back to the
|
|
|
|
`Selectable` class.
|
2021-02-16 08:26:44 -08:00
|
|
|
- Add `trim()`, `trimLeft()` and `trimRight()` extensions for text expressions
|
|
|
|
- Initial support for sub-queries in the Dart api:
|
2021-03-18 08:58:12 -07:00
|
|
|
- `Expression.isInQuery` and `isNotInQuery` for `IS IN (SELECT ...)` matching
|
|
|
|
- `subqueryExpression` to use single-column, single-row selects as values
|
|
|
|
- `existsQuery` and `notExistsQuery` for `EXISTS` expressions
|
|
|
|
- New `package:moor/remote.dart` library to access databases over any `StreamChannel`. The isolate library has been
|
|
|
|
rewritten on top of that api.
|
2021-01-20 03:06:48 -08:00
|
|
|
|
2021-01-11 11:15:10 -08:00
|
|
|
## 4.0.0-nullsafety.1
|
2020-10-23 10:29:08 -07:00
|
|
|
|
2020-12-14 11:22:27 -08:00
|
|
|
- __Breaking__: `getSingle()` and `watchSingle()` are now non-nullable and throw for empty results.
|
|
|
|
Use `getSingleOrNull()` and `watchSingleOrNull()` for the old behavior.
|
2021-01-03 08:04:33 -08:00
|
|
|
- __Breaking__: Removed `QueryEngine`, its methods have been moved to `DatabaseConnectionUser`
|
2020-11-26 08:22:59 -08:00
|
|
|
- __Breaking__: Changed the `args` parameter in `QueryExecutor` methods to `List<Object?>`
|
2020-11-22 08:40:53 -08:00
|
|
|
- __Breaking__: Removed the second type parameter from `TypedResult.read`
|
2021-03-18 08:58:12 -07:00
|
|
|
- __Breaking__: `TypedResult.read` and `TypedResult.readTable` now throw if the row does not contain the requested table
|
|
|
|
or expression (they used to return `null`).
|
2020-12-22 10:45:15 -08:00
|
|
|
- __Breaking__: `MoorWebStorage.indexedDbIfSupported` now returns a future
|
2021-03-18 08:58:12 -07:00
|
|
|
- __Breaking__: `getSingle` and `watchSingle` (and their `orNull()` variants) are now an extension on `Selectable`.
|
|
|
|
Import `package:moor/moor.dart` to files using those methods.
|
2020-11-22 08:40:53 -08:00
|
|
|
- Support null safety
|
2020-10-23 10:29:08 -07:00
|
|
|
- Changed the sql representation of text types from `VARCHAR` to `TEXT`
|
2020-10-27 09:26:56 -07:00
|
|
|
- Added extensions for `isNull` and `isNotNull`
|
2020-11-11 01:59:03 -08:00
|
|
|
- Support creating a `VmDatabase` from a raw sqlite3 `Database` via `VmDatabase.opened`
|
2020-11-16 08:03:22 -08:00
|
|
|
- New `named_parameters` build option to generate named parameters for named variables in moor files
|
2020-12-04 12:15:43 -08:00
|
|
|
- Added `Migrator.renameTable` to rename tables
|
2020-10-23 10:29:08 -07:00
|
|
|
|
2020-10-22 05:17:54 -07:00
|
|
|
## 3.4.0
|
2020-08-13 12:09:26 -07:00
|
|
|
|
2020-09-04 04:13:26 -07:00
|
|
|
- New `TableMigration` api to make complex table migrations easier. See the
|
2021-03-18 08:58:12 -07:00
|
|
|
[updated documentation](https://moor.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations) for details
|
|
|
|
on how to use this feature.
|
|
|
|
- New `DatabaseConnection.delayed` constructor to synchronously obtain a database connection that requires an async
|
|
|
|
setup. This can be useful when connecting to a `MoorIsolate`.
|
2020-08-14 12:57:49 -07:00
|
|
|
- `VmDatabase`: Create directory of database file to avoid misuse errors from sqlite3.
|
2020-08-30 04:48:47 -07:00
|
|
|
- New feature in moor files: You can now set the default value for Dart templates:
|
2021-03-18 08:58:12 -07:00
|
|
|
`filter ($predicate = TRUE): SELECT * FROM my_table WHERE $predicate`. This generates an optional named parameter in
|
|
|
|
Dart.
|
|
|
|
- New `generate_values_in_copy_with` [build option](https://moor.simonbinder.eu/docs/advanced-features/builder_options/)
|
|
|
|
. It wraps nullable columns in a `Value` in `copyWith` methods so that they can be set to `null`.
|
2020-09-30 06:39:02 -07:00
|
|
|
- Added `groupConcat`, `cast` and `coalesce` functions to the Dart query builder.
|
2020-10-22 05:17:54 -07:00
|
|
|
- Added `renameColumn` to `Migrator` to generate `ALTER TABLE RENAME COLUMN` statements.
|
2020-10-17 05:31:04 -07:00
|
|
|
- Added `VmDatabase.closeExistingInstances()` to close zombie database connections after hot restarts on some OSes.
|
2020-08-13 12:09:26 -07:00
|
|
|
|
2020-08-07 12:33:17 -07:00
|
|
|
## 3.3.1
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
- Support changing `onData` handlers for query streams. This fixes a bug occurring when using `queryStream.first`
|
|
|
|
multiple times.
|
2020-08-07 12:33:17 -07:00
|
|
|
|
2020-07-23 08:30:01 -07:00
|
|
|
## 3.3.0
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
- New `package:moor/ffi.dart` library to replace the `moor_ffi` package. When migrating, Flutter users need to depend on
|
|
|
|
the `sqlite3_flutter_libs` package as well. The changelog of `moor_ffi` contains further information about this
|
|
|
|
- New (in
|
|
|
|
generator): `apply_converters_on_variables` [build option](https://moor.simonbinder.eu/docs/advanced-features/builder_options/)
|
|
|
|
. When enabled, type converter will be enabled on variables for analyzed queries. This will be the default option in
|
|
|
|
the future.
|
2020-07-23 08:30:01 -07:00
|
|
|
|
2020-05-22 08:25:30 -07:00
|
|
|
## 3.2.0
|
|
|
|
|
|
|
|
- It's now possible to change the name of a class generated for moor-file queries. See
|
|
|
|
[the documentation](https://moor.simonbinder.eu/docs/using-sql/moor_files/#result-class-names) for details.
|
2021-03-18 08:58:12 -07:00
|
|
|
- Added the `multiLine`, `caseSensitive`, `unicode` and `doAll` flags to the `regex` sql extension method. They
|
|
|
|
require `moor_ffi` version `0.7.0` or later.
|
2020-05-22 08:25:30 -07:00
|
|
|
|
2020-05-06 12:08:47 -07:00
|
|
|
## 3.1.0
|
|
|
|
|
|
|
|
- Update companions now implement `==` and `hashCode`
|
2020-05-07 09:59:12 -07:00
|
|
|
- New `containsCase` method for text in `package:moor/extensions/moor_ffi.dart`
|
2020-05-08 11:53:58 -07:00
|
|
|
- The `toCompanion` method is back for data classes, but its generation can be disabled with a build option
|
2021-03-18 08:58:12 -07:00
|
|
|
- New
|
|
|
|
feature: [Implicit enum converters](https://moor.simonbinder.eu/docs/advanced-features/type_converters/#implicit-enum-converters)
|
|
|
|
- Added the `destructiveFallback` extension to databases. It can be used in `migrationStrategy` to delete and then
|
|
|
|
re-create all tables, indices and triggers.
|
2020-05-06 12:08:47 -07:00
|
|
|
|
2020-05-04 11:15:23 -07:00
|
|
|
## 3.0.2
|
|
|
|
|
|
|
|
- Fix update statements not escaping column names ([#539](https://github.com/simolus3/moor/issues/539))
|
|
|
|
|
2020-05-03 12:20:52 -07:00
|
|
|
## 3.0.1
|
|
|
|
|
|
|
|
- Fix `mapFromRowOrNull` not working without a prefix ([#534](https://github.com/simolus3/moor/pull/534))
|
|
|
|
|
2020-05-02 05:50:04 -07:00
|
|
|
## 3.0.0
|
2020-02-17 08:11:34 -08:00
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
- __Breaking__: `package:moor/moor_web.dart` no longer exports `package:moor/moor.dart`. If you've relied on this,
|
|
|
|
you'll now need to import `package:moor/moor.dart` as well.
|
2020-02-17 08:17:46 -08:00
|
|
|
- __Breaking__: Remove deprecated members:
|
2021-03-18 08:58:12 -07:00
|
|
|
- top-level `and`, `or` and `not` methods. Use `&`, `|` and `.not()` instead.
|
|
|
|
- top-level `year`, `month`, `day`, `hour`, `minute`, `second` methods. Use the extension member
|
|
|
|
on `Expression<DateTime>` instead.
|
|
|
|
- `InsertStatement.insertAll` (use batches instead)
|
|
|
|
- the `orReplace` boolean parameter on inserts (use `mode: InsertMode.orReplace` instead)
|
|
|
|
- remove the top-level `isIn` and `isNotIn` functions
|
|
|
|
(use the `.isIn` and `.isNotIn` instance methods instead)
|
|
|
|
- `CustomSelectStatement.execute` and `constructFetcher` - use `get()` or `watch()`, respectively
|
2020-02-17 09:05:24 -08:00
|
|
|
- __Breaking__: Remove the second type variable on `Expression` and subclasses.
|
2020-02-17 11:43:42 -08:00
|
|
|
- __Breaking__: Remove `customSelectStream` from `QueryEngine`. The `customSelect`
|
|
|
|
method now returns an `Selectable` (like `customSelectQuery`, which in turn has been deprecated).
|
2021-03-18 08:58:12 -07:00
|
|
|
- __Breaking__: Columns that are aliases to sqlite's `rowid` column are no longer considered required for inserts
|
2020-04-17 09:02:05 -07:00
|
|
|
- __Breaking__: Changes the way data classes and companions are inserted:
|
2021-03-18 08:58:12 -07:00
|
|
|
- Removed `Insertable.toCompanion`
|
|
|
|
- Added `Insertable.toColumns` to obtain a map from column names to values that should be inserted
|
|
|
|
- Removed `TableInfo.entityToSql` - use `Insertable.toColumns` instead
|
|
|
|
- __Breaking__: Renamed the `db` field in daos to `attachedDatabase`. The old field is available through an extension.
|
|
|
|
- __Breaking__: The `compact_query_methods` and `use_column_name_as_json_key_when_defined_in_moor_file` build options
|
|
|
|
are now enabled by default. This means that queries in moor files now generate a `Selectable` method by default (
|
|
|
|
instead of two methods for `get` and `watch`). Columns defined in moor files will have their sql name as json key (
|
|
|
|
moor used to transform their name to `camelCase`). You can still disable both options to keep the old behavior.
|
2020-05-03 12:13:29 -07:00
|
|
|
- __Breaking__: The last statement in a moor file must now end with a semicolon as well
|
2021-03-18 08:58:12 -07:00
|
|
|
- Batches now run statements in the order they were issued. This required a breaking change for engine implementers.
|
2020-02-16 04:26:25 -08:00
|
|
|
- Experimentally support IndexedDB to store sqlite data on the web
|
2021-03-18 08:58:12 -07:00
|
|
|
- Moor will no longer wait for query stream listeners to receive a done event when closing a database or transaction.
|
|
|
|
- Updated stream queries: They now take triggers into account and more accurately detect when an update is necessary.
|
|
|
|
- New `tableUpdates` method that can be used to listen for a subset of table updates outside of a query.
|
2020-04-04 03:22:19 -07:00
|
|
|
- New feature: Nested results for compiled queries ([#288](https://github.com/simolus3/moor/issues/288))
|
2021-03-18 08:58:12 -07:00
|
|
|
See the [documentation](https://moor.simonbinder.eu/docs/using-sql/moor_files/#nested-results) for details on how and
|
|
|
|
when to use this feature.
|
2020-04-25 03:23:37 -07:00
|
|
|
- New feature: Use sql expressions for inserts or updates with the new `custom` factory on companions
|
2021-03-18 08:58:12 -07:00
|
|
|
- New feature: Upserts in the Dart api! Read everything you need to know
|
2020-04-25 03:23:37 -07:00
|
|
|
[here](https://moor.simonbinder.eu/docs/getting-started/writing_queries/#upserts).
|
2020-04-24 11:09:46 -07:00
|
|
|
- Support using `MoorIsolates` in scenarios where only primitive messages can be passed between isolates.
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2020-03-07 08:54:36 -08:00
|
|
|
## 2.4.2
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
- Fix `beforeOpen` callback deadlocking when using the isolate executor
|
2020-03-07 08:54:36 -08:00
|
|
|
([#431](https://github.com/simolus3/moor/issues/431))
|
2020-03-08 04:03:34 -07:00
|
|
|
- Fix limit clause not being applied when using `.join` afterwards
|
|
|
|
([#433](https://github.com/simolus3/moor/issues/433))
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2020-02-25 05:15:31 -08:00
|
|
|
## 2.4.1
|
|
|
|
|
|
|
|
- Don't generate double quoted string literals in date time functions
|
|
|
|
|
2020-02-10 10:46:27 -08:00
|
|
|
## 2.4.0
|
2020-01-24 13:09:09 -08:00
|
|
|
|
|
|
|
- Support aggregate expressions and `group by` in the Dart api
|
2021-03-18 08:58:12 -07:00
|
|
|
- Support type converters in moor files!
|
|
|
|
The [documentation](https://moor.simonbinder.eu/docs/advanced-features/type_converters/)
|
2020-01-25 07:17:56 -08:00
|
|
|
has been updated to explain how to use them.
|
2020-01-30 13:08:18 -08:00
|
|
|
- Support stream queries in transactions ([#356](https://github.com/simolus3/moor/issues/365))
|
2021-03-18 08:58:12 -07:00
|
|
|
- Support table-valued functions (like `json_each` and `json_tree`) in moor files
|
2020-01-26 06:40:09 -08:00
|
|
|
[#260](https://github.com/simolus3/moor/issues/260).
|
2020-01-29 13:03:29 -08:00
|
|
|
- Fix a crash when opening a transaction without using it ([#361](https://github.com/simolus3/moor/issues/361))
|
2020-02-03 10:35:39 -08:00
|
|
|
- New `mapFromCompanion` method in generated tables to convert a `UpdateCompanion` to a model.
|
2021-03-18 08:58:12 -07:00
|
|
|
- Support generated moor classes in other builders (like `built_value`).
|
|
|
|
Details [in the docs](https://moor.simonbinder.eu/docs/advanced-features/builder_options/)
|
2020-01-24 13:09:09 -08:00
|
|
|
|
2020-01-21 08:55:41 -08:00
|
|
|
## 2.3.0
|
2019-12-25 13:22:46 -08:00
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
- New `clientDefault` method for columns. It can be used for dynamic defaults that might be different for each row. For
|
|
|
|
instance, you can generate a uuid for each row with `text().clientDefault(() => Uuid().v4()();`
|
2020-01-16 14:10:05 -08:00
|
|
|
- New CLI tool to analyze moor files: Learn more at [https://moor.simonbinder.eu/cli](https://moor.simonbinder.eu/cli)
|
2019-12-27 09:17:45 -08:00
|
|
|
- Ability to override the default `ValueSerializer` globally by using `moorRuntimeOptions.valueSerializer`.
|
2021-03-18 08:58:12 -07:00
|
|
|
- Moor files: You can now explicitly declare column types in those cases that the analyzer can't infer it:
|
2019-12-27 09:17:45 -08:00
|
|
|
```
|
|
|
|
selectVariable(:variable AS TEXT): SELECT :variable;
|
|
|
|
```
|
2020-01-04 04:22:29 -08:00
|
|
|
- Support for triggers and indices! You can declare them in a `.moor` file with a regular `CREATE TRIGGER`
|
2021-03-18 08:58:12 -07:00
|
|
|
or `CREATE INDEX` statement. Both triggers and indices will be created in the default `onCreate` function. To create
|
|
|
|
them in `onUpgrade`, use the new `createIndex` and `createTrigger` functions on a `Migrator`.
|
2020-01-04 04:22:29 -08:00
|
|
|
- Support for moor-file queries that run on initialization ([#280](https://github.com/simolus3/moor/issues/280))
|
|
|
|
Declare them like this `@create: INSERT INTO users VALUES ('default', 'user')`
|
2020-01-07 02:31:35 -08:00
|
|
|
- Support deletes in batches ([#325](https://github.com/simolus3/moor/issues/325))
|
2021-03-18 08:58:12 -07:00
|
|
|
- Reduce unnecessary queries when a stream is unsubscribed and then
|
|
|
|
re-subscribed ([#329](https://github.com/simolus3/moor/issues/329))
|
2020-01-13 11:40:46 -08:00
|
|
|
- Experimental new type inference for the sql analyzer. For details, check the
|
|
|
|
`use_experimental_inference` [build option](https://moor.simonbinder.eu/docs/advanced-features/builder_options/)
|
2020-01-21 08:55:41 -08:00
|
|
|
- Web: New `initializer` parameter to create the database when it doesn't exist
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-12-23 03:52:46 -08:00
|
|
|
## 2.2.0
|
2019-11-16 12:30:48 -08:00
|
|
|
|
2019-12-23 03:24:22 -08:00
|
|
|
- Support custom expressions for selects in the Dart API:
|
2019-11-16 12:30:48 -08:00
|
|
|
```dart
|
|
|
|
final currentBalance = accounts.income - accounts.expenses;
|
|
|
|
select(accounts).addColumns([currentBalance]).map((row) {
|
|
|
|
Account account = row.readTable(accounts);
|
|
|
|
int balanceOfAccount = row.read(currentBalance);
|
|
|
|
return ...
|
|
|
|
}).get();
|
|
|
|
```
|
2019-12-23 03:24:22 -08:00
|
|
|
- Support the `json1` and `fts5` extensions! Using them also requires version 2.2 of `moor_generator`
|
2021-03-18 08:58:12 -07:00
|
|
|
and they require `moor_ffi`. For details, see
|
|
|
|
the [documentation](https://moor.simonbinder.eu/docs/using-sql/extensions/).
|
2019-12-16 06:50:12 -08:00
|
|
|
- Standardized behavior of batches in transactions across backends
|
2021-03-18 08:58:12 -07:00
|
|
|
- Introduced `OrderingTerm.asc` and `OrderingTerm.desc` factories to construct ordering terms more easily
|
2019-11-27 03:06:19 -08:00
|
|
|
|
2019-12-12 00:54:34 -08:00
|
|
|
## 2.1.1
|
|
|
|
|
|
|
|
- Fix crash when closing a database with asserts disabled
|
|
|
|
- Web: Save the database after migrations ran
|
|
|
|
- Escape column names in insert statements, if necessary
|
|
|
|
|
2019-11-13 12:14:38 -08:00
|
|
|
## 2.1.0
|
2019-10-20 02:39:24 -07:00
|
|
|
|
2019-11-08 11:43:52 -08:00
|
|
|
- New extension methods to simplify the Dart api!
|
2021-03-18 08:58:12 -07:00
|
|
|
- Use `&`, `or` and `.not()` to combine boolean expressions.
|
|
|
|
```dart
|
|
|
|
// OLD
|
|
|
|
select(animals)..where((a) => and(not(a.isMammal), a.amountOfLegs.equals(4)))
|
|
|
|
// NEW:
|
|
|
|
select(animals)..where((a) => a.isMammal.not() & a.amountOfLegs.equals(4))
|
|
|
|
```
|
|
|
|
- Arithmetic: New `+`, `-`, `*` and `/` operators for int and double sql expressions
|
|
|
|
- New `+` operator for string concatenation
|
|
|
|
- Fix crash when `customStatement` is the first operation used on a
|
|
|
|
database ([#199](https://github.com/simolus3/moor/issues/199))
|
2019-10-31 10:41:15 -07:00
|
|
|
- Allow transactions inside a `beforeOpen` callback
|
2019-11-02 13:48:37 -07:00
|
|
|
- New `batch` method on generated databases to execute multiple queries in a single batch
|
2019-11-05 11:22:55 -08:00
|
|
|
- Experimental support to run moor on a background isolate
|
2019-11-08 12:49:23 -08:00
|
|
|
- Reduce use of parentheses in SQL code generated at runtime
|
2019-11-09 07:34:01 -08:00
|
|
|
- Query streams now emit errors that happened while running the query
|
2019-11-09 12:16:24 -08:00
|
|
|
- Upgraded the sql parser which now supports `WITH` clauses in moor files
|
2019-11-13 12:14:38 -08:00
|
|
|
- Internal refactorings on the runtime query builder
|
2019-10-20 02:39:24 -07:00
|
|
|
|
2019-10-11 04:17:50 -07:00
|
|
|
## 2.0.1
|
2019-10-05 04:38:34 -07:00
|
|
|
|
|
|
|
- Introduced `isBetween` and `isBetweenValues` methods for comparable expressions (int, double, datetime)
|
|
|
|
to check values for both an upper and lower bound
|
2019-10-05 12:24:41 -07:00
|
|
|
- Automatically map `BOOLEAN` and `DATETIME` columns declared in a sql file to the appropriate type
|
|
|
|
(both used to be `double` before).
|
2019-10-10 08:30:22 -07:00
|
|
|
- Fix streams not emitting cached data when listening multiple times
|
2021-03-18 08:58:12 -07:00
|
|
|
- __Breaking__: Remove the type parameter from `Insertable.createCompanion` (it was declared as an internal method)
|
|
|
|
|
|
|
|
__2.0.1+1__: Fix crash when `customStatement` is the first operation used on a database
|
2019-10-20 12:10:23 -07:00
|
|
|
([#199](https://github.com/simolus3/moor/issues/199))
|
2019-10-05 04:38:34 -07:00
|
|
|
|
2019-09-13 12:04:15 -07:00
|
|
|
## 2.0.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-09-14 12:54:16 -07:00
|
|
|
This is the first major update after the initial release and moor and we have a lot to cover:
|
2021-03-18 08:58:12 -07:00
|
|
|
`.moor` files can now have their own imports and queries, you can embed Dart in sql queries using the new templates
|
|
|
|
feature and we have a prototype of a pure-Dart SQL IDE ready. Finally, we also removed a variety of deprecated features.
|
|
|
|
See the breaking changes section to learn what components are affected and what alternatives are available.
|
2019-09-13 12:04:15 -07:00
|
|
|
|
2019-09-14 12:54:16 -07:00
|
|
|
### New features
|
2019-09-13 12:04:15 -07:00
|
|
|
|
2019-09-14 12:54:16 -07:00
|
|
|
#### Updates to the sql parser
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-09-14 12:54:16 -07:00
|
|
|
`.moor` files were introduced in moor 1.7 as an experimental way to declare tables by using
|
2021-03-18 08:58:12 -07:00
|
|
|
`CREATE TABLE` statements. In this version, they become stable and support their own import and query system. This
|
|
|
|
allows you to write queries in their own file:
|
2019-09-14 12:54:16 -07:00
|
|
|
|
|
|
|
```sql
|
2021-03-18 08:58:12 -07:00
|
|
|
CREATE TABLE users
|
|
|
|
(
|
|
|
|
id INT NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
|
|
name VARCHAR NOT NULL
|
2019-09-14 12:54:16 -07:00
|
|
|
);
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
findByName
|
|
|
|
:
|
|
|
|
SELECT *
|
|
|
|
FROM users
|
|
|
|
WHERE name LIKE :query;
|
2019-09-14 12:54:16 -07:00
|
|
|
```
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
When this file is included from a `@UseMoor` annotation, moor will generate methods to run the query. Of course, you can
|
|
|
|
also write Dart queries for tables declared in sql:
|
|
|
|
|
2019-09-14 12:54:16 -07:00
|
|
|
```dart
|
|
|
|
Stream<User> loadUserById(int id) {
|
2021-03-18 08:58:12 -07:00
|
|
|
return (select(users)
|
|
|
|
..where((u) => u.id.equals(2))).watchSingle();
|
2019-09-14 12:54:16 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
Moor files can also import other moor files by using an `import 'other.moor';` statement at the top. Then, all tables
|
|
|
|
defined in `other.moor` will also be available to the current file.
|
|
|
|
|
|
|
|
Moor takes Dart and SQL interop even further with the new "Dart in SQL templates". You can define a query like this:
|
2019-09-14 12:54:16 -07:00
|
|
|
|
|
|
|
```sql
|
2021-03-18 08:58:12 -07:00
|
|
|
findDynamic
|
|
|
|
:
|
|
|
|
SELECT *
|
|
|
|
FROM users
|
|
|
|
WHERE $condition;
|
2019-09-14 12:54:16 -07:00
|
|
|
```
|
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
And moor will generate a method `findDynamic(Expression<bool, BoolType> condition)` for you. This allows you to bind the
|
|
|
|
template with a predicate as complex as you'd like. At the moment, Dart templates are supported for
|
|
|
|
expressions, `OrderBy`, `OrderingTerm` and `Limit`.
|
2019-09-14 12:54:16 -07:00
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
`INSERT` statements can now be used as a compiled statement - both in moor files and in a `@UseMoor` or `@UseDao`
|
|
|
|
annotation. A new builtin linter will even warn you when you forget to provide a value for a non-nullable column - right
|
|
|
|
at compile time!
|
2019-09-14 12:54:16 -07:00
|
|
|
|
2021-03-18 08:58:12 -07:00
|
|
|
And finally, we now generate better query code when queries only return a single column. Instead of generating a whole
|
|
|
|
new class for that, we simply return the value directly.
|
2019-09-14 12:54:16 -07:00
|
|
|
|
|
|
|
#### Experimental ffi support
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
We released an experimental version of moor built on top of `dart:ffi`. It works cross-platform and is much, much faster
|
|
|
|
than `moor_flutter`. It you want to try it out, read the docs [here](https://moor.simonbinder.eu/docs/other-engines/vm/)
|
|
|
|
.
|
2019-09-13 12:04:15 -07:00
|
|
|
|
2019-09-14 11:54:13 -07:00
|
|
|
### Minor changes
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
- a `Constant<String>` can now be written to SQL, it used to throw before. This is useful if you need default values for
|
|
|
|
strings columns. This also works for `BLOBS`
|
2019-10-01 08:58:17 -07:00
|
|
|
(`Constant<Uint8List>`).
|
2021-03-18 08:58:12 -07:00
|
|
|
- new `LazyDatabase` for when you want to construct a database asynchronously (for instance, if you first need to find a
|
|
|
|
file before you can open a database).
|
2019-09-14 11:54:13 -07:00
|
|
|
|
2019-09-13 12:04:15 -07:00
|
|
|
### Breaking changes
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
- __THIS LIKELY AFFECTS YOUR APP:__ Removed the `transaction` parameter for callbacks in transactions and `beforeOpen`
|
|
|
|
callbacks. So, instead of writing
|
2019-09-13 12:04:15 -07:00
|
|
|
```dart
|
|
|
|
transaction((t) async {
|
|
|
|
await t.update(table)...;
|
|
|
|
});
|
|
|
|
```
|
|
|
|
simply write
|
|
|
|
```dart
|
|
|
|
transaction(() async {
|
|
|
|
await update(table)...;
|
|
|
|
});
|
|
|
|
```
|
|
|
|
Similarly, instead of using `onOpen: (db, details) async {...}`, use
|
2021-03-18 08:58:12 -07:00
|
|
|
`onOpen: (details) async {...}`. You don't have to worry about calling methods on your database instead of a
|
|
|
|
transaction objects. They will be delegated automatically.
|
|
|
|
|
2019-09-13 12:04:15 -07:00
|
|
|
On a similar note, we also removed the `operateOn` parameter from compiled queries.
|
2019-09-14 11:54:13 -07:00
|
|
|
- Compiled queries that return only a single column (e.g. `SELECT COUNT(*) FROM users`)
|
2021-03-18 08:58:12 -07:00
|
|
|
will just return their value (in this case, an `int`) now. Moor no longer generates a new class in that case.
|
2019-09-13 12:04:15 -07:00
|
|
|
- Removed `MigrationStrategy.onFinished`. Use `beforeOpen` instead.
|
2021-03-18 08:58:12 -07:00
|
|
|
- Compiled sql queries starting with an underscore will now generate private match queries. Previously, the
|
|
|
|
query `_allUsers` would generate a `watchAllUsers` method, that has been adopted to `_watchAllUsers`.
|
|
|
|
The `generate_private_watch_methods` builder option, which backported this fix to older versions, has thus been
|
|
|
|
removed.
|
2019-09-13 12:12:51 -07:00
|
|
|
- Removed `InsertStatement.insertOrReplace`. Use `insert(data, orReplace: true)` instead.
|
2019-10-01 08:58:17 -07:00
|
|
|
- Removed the diff util and `MoorAnimatedList`. Use a third party library for that.
|
2019-09-13 12:04:15 -07:00
|
|
|
|
2019-09-04 13:19:20 -07:00
|
|
|
## 1.7.2
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
- Fixed a race condition that caused the database to be opened multiple times on slower devices. This problem was
|
|
|
|
introduced in `1.7.0` and was causing problems during migrations.
|
2019-09-04 13:19:20 -07:00
|
|
|
|
2019-08-25 13:44:28 -07:00
|
|
|
## 1.7.1
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-08-25 13:44:28 -07:00
|
|
|
- Better documentation on `getSingle` and `watchSingle` for queries.
|
|
|
|
- Fix `INTEGER NOT NULL PRIMARY KEY` wrongly requiring a value during insert (this never affected
|
|
|
|
`AUTOINCREMENT` columns, and only affects columns declared in a `.moor` file)
|
|
|
|
|
2019-08-22 03:27:39 -07:00
|
|
|
## 1.7.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-07-28 04:44:25 -07:00
|
|
|
- Support custom columns via type converters. See the [docs](https://moor.simonbinder.eu/type_converters)
|
2021-03-18 08:58:12 -07:00
|
|
|
for details on how to use this feature.
|
|
|
|
- Transactions now roll back when not completed successfully, they also rethrow the exception to make debugging easier.
|
2019-07-28 04:44:25 -07:00
|
|
|
- New `backends` api, making it easier to write database drivers that work with moor. Apart from
|
2021-03-18 08:58:12 -07:00
|
|
|
`moor_flutter`, new experimental backends can be checked out from git:
|
|
|
|
1. `encrypted_moor`: An encrypted moor database: https://github.com/simolus3/moor/tree/develop/extras/encryption
|
2019-07-31 11:47:58 -07:00
|
|
|
- The compiled sql feature is no longer experimental and will stay stable until a major version bump
|
2021-03-18 08:58:12 -07:00
|
|
|
- New, experimental support for `.moor` files! Instead of declaring your tables in Dart, you can choose to declare them
|
|
|
|
with sql by writing the `CREATE TABLE` statement in a `.moor` file. You can then use these tables in the database and
|
|
|
|
with daos by using the `include` parameter on `@UseMoor` and `@UseDao`. Again, please notice that this is an
|
|
|
|
experimental api and there might be some hiccups. Please report any issues you run into.
|
|
|
|
|
2019-07-12 01:52:42 -07:00
|
|
|
## 1.6.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-07-10 08:55:57 -07:00
|
|
|
- Experimental web support! See [the documentation](https://moor.simonbinder.eu/web) for details.
|
2021-03-18 08:58:12 -07:00
|
|
|
- Make transactions easier to use: Thanks to some Dart async magic, you no longer need to run queries on the transaction
|
|
|
|
explicitly. This
|
2019-07-10 08:55:57 -07:00
|
|
|
```dart
|
|
|
|
Future deleteCategory(Category category) {
|
|
|
|
return transaction((t) async {
|
|
|
|
await t.delete(categories).delete(category);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
```
|
|
|
|
is now the same as this (notice how we don't have to use the `t.` in front of the delete)
|
|
|
|
```dart
|
|
|
|
Future deleteCategory(Category category) {
|
|
|
|
return transaction((t) async {
|
|
|
|
await delete(categories).delete(category);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
```
|
2021-03-18 08:58:12 -07:00
|
|
|
This makes it much easier to compose operations by extracting them into methods, as you don't have to worry about not
|
|
|
|
using the `t` parameter.
|
2019-07-10 08:55:57 -07:00
|
|
|
- Moor now provides syntax sugar for list parameters in compiled custom queries
|
2021-03-18 08:58:12 -07:00
|
|
|
(`SELECT * FROM entries WHERE id IN ?`)
|
2019-07-08 14:03:03 -07:00
|
|
|
- Support `COLLATE` expressions.
|
2019-07-10 08:55:57 -07:00
|
|
|
- Date time columns are now comparable
|
|
|
|
- The `StringType` now supports arbitrary data from sqlite ([#70](https://github.com/simolus3/moor/pull/70)).
|
|
|
|
Thanks, [knaeckeKami](https://github.com/knaeckeKami)!
|
2019-07-12 01:52:42 -07:00
|
|
|
- Bugfixes related to stream queries and `LIMIT` clauses.
|
2019-07-07 04:03:15 -07:00
|
|
|
|
2019-07-02 12:46:04 -07:00
|
|
|
## 1.5.1
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-07-03 11:04:09 -07:00
|
|
|
- Fixed an issue where transformed streams would not always update
|
2021-03-18 08:58:12 -07:00
|
|
|
- Emit a `INSERT INTO table DEFAULT VALUES` when appropriate. Moor used to generate invalid sql before.
|
2019-07-02 12:46:04 -07:00
|
|
|
|
2019-06-21 01:27:14 -07:00
|
|
|
## 1.5.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
This version introduces some new concepts and features, which are explained in more detail below. Here is a quick
|
|
|
|
overview of the new features:
|
|
|
|
|
|
|
|
- More consistent and reliable callbacks for migrations. You can now use `MigrationStrategy.beforeOpen`
|
|
|
|
to run queries after migrations, but before fully opening the database. This is useful to initialize data.
|
2019-06-30 13:16:58 -07:00
|
|
|
- Greatly expanded documentation, introduced additional checks to provide more helpful error messages
|
2021-03-18 08:58:12 -07:00
|
|
|
- New `getSingle` and `watchSingle` methods on queries: Queries that you know will only return one row can now be
|
|
|
|
instructed to return the value directly instead of wrapping it in a list.
|
|
|
|
- New "update companion" classes to clearly separate between absent values and explicitly setting values back to null -
|
|
|
|
explained below.
|
|
|
|
- Experimental support for compiled sql queries: __Moor can now generate typesafe APIs for written sql__. Read on to get
|
|
|
|
started.
|
|
|
|
|
2019-06-30 03:01:46 -07:00
|
|
|
### Update companions
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
Newly introduced "Update companions" allow you to insert or update data more precisely than before. Previously, there
|
|
|
|
was no clear separation between "null" and absent values. For instance, let's say we had a table "users" that stores an
|
|
|
|
id, a name, and an age. Now, let's say we wanted to set the age of a user to null without changing its name. Would we
|
|
|
|
use `User(age: null)`? Here, the `name` column would implicitly be set to null, so we can't cleanly separate that.
|
|
|
|
However, with `UsersCompanion(age: Value(null))`, we know the difference between `Value(null)` and the
|
2019-06-30 03:01:46 -07:00
|
|
|
default `Value.absent()`.
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
Don't worry, all your existing code will continue to work, this change is fully backwards compatible. You might get
|
|
|
|
analyzer warnings about missing required fields. The migration to update companions will fix that. Replacing normal
|
|
|
|
classes with their update companions is simple and the only thing needed to fix that.
|
|
|
|
The [documentation](https://moor.simonbinder.eu/queries/#updates-and-deletes)
|
|
|
|
has been updated to reflect this. If you have additional questions, feel free to
|
2019-06-30 13:16:58 -07:00
|
|
|
[create an issue](https://github.com/simolus3/moor/issues/new).
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-06-30 03:01:46 -07:00
|
|
|
### Compiled sql queries
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
Experimental support for compile time custom statements. Sounds super boring, but it actually gives you a fluent way to
|
|
|
|
write queries in pure sql. The moor generator will figure out what your queries return and automatically generate the
|
|
|
|
boring mapping part. Head on to
|
2019-06-30 13:16:58 -07:00
|
|
|
[the documentation](https://moor.simonbinder.eu/queries/custom) to find out how to use this new feature.
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
Please note that this feature is in an experimental state: Expect minor, but breaking changes in the API and in the
|
|
|
|
generated code. Also, if you run into any issues with this feature,
|
2019-06-30 03:01:46 -07:00
|
|
|
[reporting them](https://github.com/simolus3/moor/issues/new) would be super appreciated.
|
2019-06-21 01:27:14 -07:00
|
|
|
|
2019-06-09 03:27:24 -07:00
|
|
|
## 1.4.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-06-09 03:27:24 -07:00
|
|
|
- Added the `RealColumn`, which stores floating point values
|
2021-03-18 08:58:12 -07:00
|
|
|
- Better configuration for the serializer with the `JsonKey` annotation and the ability to use a
|
|
|
|
custom `ValueSerializer`
|
2019-06-09 03:27:24 -07:00
|
|
|
|
2019-04-14 07:47:15 -07:00
|
|
|
## 1.3.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-04-14 07:47:15 -07:00
|
|
|
- Moor now supports table joins
|
2021-03-18 08:58:12 -07:00
|
|
|
- Added table aliases
|
2019-04-14 07:47:15 -07:00
|
|
|
- Default values for columns: Just use the `withDefault` method when declaring a column
|
2021-03-18 08:58:12 -07:00
|
|
|
- added expressions that resolve to the current date or time
|
2019-04-14 07:47:15 -07:00
|
|
|
- Fixed a crash that would occur if the first operation was a transaction
|
|
|
|
- Better support for custom expressions as part of a regular query
|
|
|
|
- Faster hashcode implementation in generated data classes
|
|
|
|
|
2019-03-10 11:45:32 -07:00
|
|
|
## 1.2.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
|
|
|
- __Breaking__: Generated DAO classes are now called `_$YourNameHere`, it used to be just `_YourNameHere` (without the
|
|
|
|
dollar sign)
|
2019-03-10 11:45:32 -07:00
|
|
|
- Blob data type
|
2019-03-15 04:56:22 -07:00
|
|
|
- `insertOrReplace` method for insert statements
|
2019-03-27 10:56:14 -07:00
|
|
|
- DAOs can now operate on transactions
|
|
|
|
- Custom constraints
|
2021-03-18 08:58:12 -07:00
|
|
|
- Query streams are now cached so that equal queries yield identical streams. This can improve performance.
|
2019-03-10 11:45:32 -07:00
|
|
|
|
2019-03-10 04:54:50 -07:00
|
|
|
## 1.1.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-03-10 04:54:50 -07:00
|
|
|
- Transactions
|
|
|
|
|
2019-02-03 04:56:31 -08:00
|
|
|
## 1.0.0
|
2021-03-18 08:58:12 -07:00
|
|
|
|
2019-03-09 11:41:02 -08:00
|
|
|
- Initial version of the Moor library
|