Remove InsertStatement.insertOrReplace

This commit is contained in:
Simon Binder 2019-09-13 21:12:51 +02:00
parent e9225cf759
commit 456392333d
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 1 additions and 15 deletions

View File

@ -34,6 +34,7 @@ TODO: Properly describe these additions when they're finalized:
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.
- Removed `InsertStatement.insertOrReplace`. Use `insert(data, orReplace: true)` instead.
## 1.7.2
- Fixed a race condition that caused the database to be opened multiple times on slower devices.

View File

@ -4,8 +4,6 @@ import 'package:meta/meta.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'update.dart';
class InsertStatement<D extends DataClass> {
@protected
final QueryEngine database;
@ -72,19 +70,6 @@ class InsertStatement<D extends DataClass> {
database.markTablesUpdated({table});
}
/// Updates the row with the same primary key in the database or creates one
/// if it doesn't exist.
///
/// Behaves similar to [UpdateStatement.replace], meaning that all fields from
/// [entity] will be written to override rows with the same primary key, which
/// includes setting columns with null values back to null.
///
/// However, if no such row exists, a new row will be written instead.
@Deprecated('Use insert with orReplace: true instead')
Future<void> insertOrReplace(Insertable<D> entity) async {
return await insert(entity, orReplace: true);
}
GenerationContext _createContext(Insertable<D> entry, bool replace) {
final map = table.entityToSql(entry.createCompanion(true))
..removeWhere((_, value) => value == null);