From 603c9a20cc410d0be8db55b8693d8111413a6b06 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sun, 3 Jan 2021 17:04:33 +0100 Subject: [PATCH] Remove QueryEngine mixin --- moor/CHANGELOG.md | 1 + moor/lib/moor.dart | 1 - moor/lib/src/dsl/database.dart | 2 +- moor/lib/src/runtime/api/batch.dart | 33 +++-- moor/lib/src/runtime/api/connection.dart | 66 ---------- ...query_engine.dart => connection_user.dart} | 117 +++++++++++------- moor/lib/src/runtime/api/dao_base.dart | 5 +- moor/lib/src/runtime/api/db_base.dart | 6 +- moor/lib/src/runtime/api/runtime_api.dart | 3 +- .../runtime/executor/helpers/delegates.dart | 2 +- .../src/runtime/executor/transactions.dart | 25 ++-- .../query_builder/generation_context.dart | 5 +- .../query_builder/statements/delete.dart | 5 +- .../query_builder/statements/insert.dart | 2 +- .../query_builder/statements/query.dart | 6 +- .../statements/select/custom_select.dart | 4 +- .../statements/select/select.dart | 6 +- .../statements/select/select_with_join.dart | 4 +- .../query_builder/statements/update.dart | 2 +- 19 files changed, 121 insertions(+), 174 deletions(-) rename moor/lib/src/runtime/api/{query_engine.dart => connection_user.dart} (82%) diff --git a/moor/CHANGELOG.md b/moor/CHANGELOG.md index 71cd0f1a..2b15c930 100644 --- a/moor/CHANGELOG.md +++ b/moor/CHANGELOG.md @@ -2,6 +2,7 @@ - __Breaking__: `getSingle()` and `watchSingle()` are now non-nullable and throw for empty results. Use `getSingleOrNull()` and `watchSingleOrNull()` for the old behavior. +- __Breaking__: Removed `QueryEngine`, its methods have been moved to `DatabaseConnectionUser` - __Breaking__: Changed the `args` parameter in `QueryExecutor` methods to `List` - __Breaking__: Removed the second type parameter from `TypedResult.read` - __Breaking__: `MoorWebStorage.indexedDbIfSupported` now returns a future diff --git a/moor/lib/moor.dart b/moor/lib/moor.dart index 6fec472d..8902322d 100644 --- a/moor/lib/moor.dart +++ b/moor/lib/moor.dart @@ -12,7 +12,6 @@ export 'package:moor/src/runtime/query_builder/query_builder.dart'; export 'package:moor/src/runtime/executor/connection_pool.dart'; export 'package:moor/src/runtime/executor/executor.dart'; -export 'package:moor/src/runtime/executor/transactions.dart'; export 'package:moor/src/runtime/custom_result_set.dart'; export 'package:moor/src/runtime/data_verification.dart'; export 'package:moor/src/runtime/data_class.dart'; diff --git a/moor/lib/src/dsl/database.dart b/moor/lib/src/dsl/database.dart index b976c31a..44262805 100644 --- a/moor/lib/src/dsl/database.dart +++ b/moor/lib/src/dsl/database.dart @@ -7,7 +7,7 @@ part of 'dsl.dart'; /// run the build runner using (flutter packages) pub run build_runner build. /// Moor will have generated a class that has the same name as your database /// class, but with `_$` as a prefix. You can now extend that class and provide -/// a [QueryEngine] to use moor: +/// a [QueryExecutor] to use moor: /// ```dart /// class MyDatabase extends _$MyDatabase { // _$MyDatabase was generated /// MyDatabase(): diff --git a/moor/lib/src/runtime/api/batch.dart b/moor/lib/src/runtime/api/batch.dart index 85328e1f..d540af71 100644 --- a/moor/lib/src/runtime/api/batch.dart +++ b/moor/lib/src/runtime/api/batch.dart @@ -8,14 +8,14 @@ class Batch { final Map _sqlToIndex = {}; final List _createdArguments = []; - final QueryEngine _engine; + final DatabaseConnectionUser _user; /// Whether we should start a transaction when completing. final bool _startTransaction; final Set _createdUpdates = {}; - Batch._(this._engine, this._startTransaction); + Batch._(this._user, this._startTransaction); void _addUpdate(TableInfo table, UpdateKind kind) { _createdUpdates.add(TableUpdate.onTable(table, kind: kind)); @@ -41,7 +41,7 @@ class Batch { {InsertMode? mode, DoUpdate? onConflict}) { _addUpdate(table, UpdateKind.insert); final actualMode = mode ?? InsertMode.insert; - final context = InsertStatement(_engine, table) + final context = InsertStatement(_user, table) .createContext(row, actualMode, onConflict: onConflict); _addContext(context); } @@ -84,7 +84,7 @@ class Batch { TableInfo table, Insertable row, {Expression Function(T table)? where}) { _addUpdate(table, UpdateKind.update); - final stmt = UpdateStatement(_engine, table); + final stmt = UpdateStatement(_user, table); if (where != null) stmt.where(where); stmt.write(row, dontExecute: true); @@ -103,8 +103,7 @@ class Batch { Insertable row, ) { _addUpdate(table, UpdateKind.update); - final stmt = UpdateStatement(_engine, table) - ..replace(row, dontExecute: true); + final stmt = UpdateStatement(_user, table)..replace(row, dontExecute: true); _addContext(stmt.constructQuery()); } @@ -119,23 +118,23 @@ class Batch { /// Deletes [row] from the [table] when this batch is executed. /// /// See also: - /// - [QueryEngine.delete] + /// - [DatabaseConnectionUser.delete] /// - [DeleteStatement.delete] void delete( TableInfo table, Insertable row) { _addUpdate(table, UpdateKind.delete); - final stmt = DeleteStatement(_engine, table)..whereSamePrimaryKey(row); + final stmt = DeleteStatement(_user, table)..whereSamePrimaryKey(row); _addContext(stmt.constructQuery()); } /// Deletes all rows from [table] matching the provided [filter]. /// /// See also: - /// - [QueryEngine.delete] + /// - [DatabaseConnectionUser.delete] void deleteWhere( TableInfo table, Expression Function(T tbl) filter) { _addUpdate(table, UpdateKind.delete); - final stmt = DeleteStatement(_engine, table)..where(filter); + final stmt = DeleteStatement(_user, table)..where(filter); _addContext(stmt.constructQuery()); } @@ -146,8 +145,8 @@ class Batch { /// inspect the return value of individual statements. /// /// See also: - /// - [QueryEngine.customStatement], the equivalent method outside of - /// batches. + /// - [DatabaseConnectionUser.customStatement], the equivalent method outside + /// of batches. void customStatement(String sql, [List? args]) { _addSqlAndArguments(sql, args ?? const []); } @@ -168,14 +167,14 @@ class Batch { } Future _commit() async { - await _engine.executor.ensureOpen(_engine.attachedDatabase); + await _user.executor.ensureOpen(_user.attachedDatabase); if (_startTransaction) { TransactionExecutor? transaction; try { - transaction = _engine.executor.beginTransaction(); - await transaction.ensureOpen(_engine.attachedDatabase); + transaction = _user.executor.beginTransaction(); + await transaction.ensureOpen(_user.attachedDatabase); await _runWith(transaction); @@ -185,10 +184,10 @@ class Batch { rethrow; } } else { - await _runWith(_engine.executor); + await _runWith(_user.executor); } - _engine.notifyUpdates(_createdUpdates); + _user.notifyUpdates(_createdUpdates); } Future _runWith(QueryExecutor executor) { diff --git a/moor/lib/src/runtime/api/connection.dart b/moor/lib/src/runtime/api/connection.dart index 5f246228..984d2901 100644 --- a/moor/lib/src/runtime/api/connection.dart +++ b/moor/lib/src/runtime/api/connection.dart @@ -65,69 +65,3 @@ class DatabaseConnection { return DatabaseConnection(typeSystem, executor, streamQueries); } } - -/// Manages a [DatabaseConnection] to send queries to the database. -abstract class DatabaseConnectionUser { - /// The database connection used by this [DatabaseConnectionUser]. - @protected - final DatabaseConnection connection; - - /// The type system to use with this database. The type system is responsible - /// for mapping Dart objects into sql expressions and vice-versa. - SqlTypeSystem get typeSystem => connection.typeSystem; - - /// The executor to use when queries are executed. - QueryExecutor get executor => connection.executor; - - /// Manages active streams from select statements. - @visibleForTesting - @protected - StreamQueryStore get streamQueries => connection.streamQueries; - - /// Constructs a database connection user, which is responsible to store query - /// streams, wrap the underlying executor and perform type mapping. - DatabaseConnectionUser(SqlTypeSystem typeSystem, QueryExecutor executor, - {StreamQueryStore? streamQueries}) - : connection = DatabaseConnection( - typeSystem, executor, streamQueries ?? StreamQueryStore()); - - /// Creates another [DatabaseConnectionUser] by referencing the implementation - /// from the [other] user. - DatabaseConnectionUser.delegate(DatabaseConnectionUser other, - {SqlTypeSystem? typeSystem, - QueryExecutor? executor, - StreamQueryStore? streamQueries}) - : connection = DatabaseConnection( - typeSystem ?? other.connection.typeSystem, - executor ?? other.connection.executor, - streamQueries ?? other.connection.streamQueries, - ); - - /// Constructs a [DatabaseConnectionUser] that will use the provided - /// [DatabaseConnection]. - DatabaseConnectionUser.fromConnection(this.connection); - - /// Creates and auto-updating stream from the given select statement. This - /// method should not be used directly. - Stream createStream(QueryStreamFetcher stmt) => - streamQueries.registerStream(stmt); - - /// Creates a copy of the table with an alias so that it can be used in the - /// same query more than once. - /// - /// Example which uses the same table (here: points) more than once to - /// differentiate between the start and end point of a route: - /// ``` - /// var source = alias(points, 'source'); - /// var destination = alias(points, 'dest'); - /// - /// select(routes).join([ - /// innerJoin(source, routes.startPoint.equalsExp(source.id)), - /// innerJoin(destination, routes.startPoint.equalsExp(destination.id)), - /// ]); - /// ``` - T alias( - TableInfo table, String alias) { - return table.createAlias(alias).asDslTable; - } -} diff --git a/moor/lib/src/runtime/api/query_engine.dart b/moor/lib/src/runtime/api/connection_user.dart similarity index 82% rename from moor/lib/src/runtime/api/query_engine.dart rename to moor/lib/src/runtime/api/connection_user.dart index 06d0cffc..80cfd217 100644 --- a/moor/lib/src/runtime/api/query_engine.dart +++ b/moor/lib/src/runtime/api/connection_user.dart @@ -5,50 +5,77 @@ const _zoneRootUserKey = #DatabaseConnectionUser; typedef _CustomWriter = Future Function( QueryExecutor e, String sql, List vars); -/// Mixin for a [DatabaseConnectionUser]. Provides an API to execute both -/// high-level and custom queries and fetch their results. -mixin QueryEngine on DatabaseConnectionUser { - /// Whether this connection user is "top level", e.g. there is no parent - /// connection user. We consider a [GeneratedDatabase] and a - /// [DatabaseAccessor] to be top-level, while a [Transaction] or a - /// [BeforeOpenRunner] aren't. - /// - /// If any query method is called on a [topLevel] database user, we check if - /// it could instead be delegated to a child executor. For instance, consider - /// this code, assuming its part of a subclass of [GeneratedDatabase]: - /// ```dart - /// void example() { - /// transaction((t) async { - /// await update(table).write(/*...*/) - /// }); - /// } - /// ``` - /// Here, the `update` method would be called on the [GeneratedDatabase] - /// although it is very likely that the user meant to call it on the - /// [Transaction] t. We can detect this by calling the function passed to - /// `transaction` in a forked [Zone]. +/// Manages a [DatabaseConnection] to send queries to the database. +abstract class DatabaseConnectionUser { + /// The database connection used by this [DatabaseConnectionUser]. @protected - bool get topLevel => false; + final DatabaseConnection connection; - /// The database that this query engine is attached to. + /// The database class that this user is attached to. @visibleForOverriding GeneratedDatabase get attachedDatabase; - /// We can detect when a user called methods on the wrong [QueryEngine] - /// (e.g. calling [QueryEngine.into] in a transaction, where - /// [QueryEngine.into] should have been called instead). See the documentation - /// of [topLevel] on how this works. - QueryEngine get _resolvedEngine { - if (!topLevel) { - // called directly in a transaction / other child callback, so use this - // instance directly - return this; - } else { - // if an overridden executor has been specified for this zone (this will - // happen for transactions), use that one. - final resolved = Zone.current[_zoneRootUserKey]; - return (resolved as QueryEngine?) ?? this; - } + /// The type system to use with this database. The type system is responsible + /// for mapping Dart objects into sql expressions and vice-versa. + SqlTypeSystem get typeSystem => connection.typeSystem; + + /// The executor to use when queries are executed. + QueryExecutor get executor => connection.executor; + + /// Manages active streams from select statements. + @visibleForTesting + @protected + StreamQueryStore get streamQueries => connection.streamQueries; + + /// Constructs a database connection user, which is responsible to store query + /// streams, wrap the underlying executor and perform type mapping. + DatabaseConnectionUser(SqlTypeSystem typeSystem, QueryExecutor executor, + {StreamQueryStore? streamQueries}) + : connection = DatabaseConnection( + typeSystem, executor, streamQueries ?? StreamQueryStore()); + + /// Creates another [DatabaseConnectionUser] by referencing the implementation + /// from the [other] user. + DatabaseConnectionUser.delegate(DatabaseConnectionUser other, + {SqlTypeSystem? typeSystem, + QueryExecutor? executor, + StreamQueryStore? streamQueries}) + : connection = DatabaseConnection( + typeSystem ?? other.connection.typeSystem, + executor ?? other.connection.executor, + streamQueries ?? other.connection.streamQueries, + ); + + /// Constructs a [DatabaseConnectionUser] that will use the provided + /// [DatabaseConnection]. + DatabaseConnectionUser.fromConnection(this.connection); + + /// Creates and auto-updating stream from the given select statement. This + /// method should not be used directly. + Stream createStream(QueryStreamFetcher stmt) => + streamQueries.registerStream(stmt); + + /// Creates a copy of the table with an alias so that it can be used in the + /// same query more than once. + /// + /// Example which uses the same table (here: points) more than once to + /// differentiate between the start and end point of a route: + /// ``` + /// var source = alias(points, 'source'); + /// var destination = alias(points, 'dest'); + /// + /// select(routes).join([ + /// innerJoin(source, routes.startPoint.equalsExp(source.id)), + /// innerJoin(destination, routes.startPoint.equalsExp(destination.id)), + /// ]); + /// ``` + T alias( + TableInfo table, String alias) { + return table.createAlias(alias).asDslTable; + } + + DatabaseConnectionUser get _resolvedEngine { + return (Zone.current[_zoneRootUserKey] as DatabaseConnectionUser?) ?? this; } /// Marks the tables as updated. This method will be called internally @@ -335,7 +362,7 @@ mixin QueryEngine on DatabaseConnectionUser { final transactionExecutor = executor.beginTransaction(); final transaction = Transaction(this, transactionExecutor); - return _runEngineZoned(transaction, () async { + return _runConnectionZoned(transaction, () async { var success = false; try { final result = await action(); @@ -396,13 +423,11 @@ mixin QueryEngine on DatabaseConnectionUser { } /// Runs [calculation] in a forked [Zone] that has its [_resolvedEngine] set - /// to the [engine]. - /// - /// For details, see the documentation at [topLevel]. + /// to the [user]. @protected - Future _runEngineZoned( - QueryEngine engine, Future Function() calculation) { - return runZoned(calculation, zoneValues: {_zoneRootUserKey: engine}); + Future _runConnectionZoned( + DatabaseConnectionUser user, Future Function() calculation) { + return runZoned(calculation, zoneValues: {_zoneRootUserKey: user}); } /// Will be used by generated code to resolve inline Dart components in sql. diff --git a/moor/lib/src/runtime/api/dao_base.dart b/moor/lib/src/runtime/api/dao_base.dart index 1fabc516..6e62755e 100644 --- a/moor/lib/src/runtime/api/dao_base.dart +++ b/moor/lib/src/runtime/api/dao_base.dart @@ -8,10 +8,7 @@ part of 'runtime_api.dart'; /// For details on how to write a dao, see [UseDao]. /// [T] should be the associated database class you wrote. abstract class DatabaseAccessor - extends DatabaseConnectionUser with QueryEngine { - @override - final bool topLevel = true; - + extends DatabaseConnectionUser { /// The main database instance for this dao @override final T attachedDatabase; diff --git a/moor/lib/src/runtime/api/db_base.dart b/moor/lib/src/runtime/api/db_base.dart index 260fef25..ddb0a785 100644 --- a/moor/lib/src/runtime/api/db_base.dart +++ b/moor/lib/src/runtime/api/db_base.dart @@ -11,11 +11,7 @@ Map _openedDbCount = {}; /// A base class for all generated databases. abstract class GeneratedDatabase extends DatabaseConnectionUser - with QueryEngine implements QueryExecutorUser { - @override - bool get topLevel => true; - @override GeneratedDatabase get attachedDatabase => this; @@ -112,7 +108,7 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser @override @nonVirtual Future beforeOpen(QueryExecutor executor, OpeningDetails details) { - return _runEngineZoned(BeforeOpenRunner(this, executor), () async { + return _runConnectionZoned(BeforeOpenRunner(this, executor), () async { if (details.wasCreated) { final migrator = createMigrator(); await _resolvedMigration.onCreate(migrator); diff --git a/moor/lib/src/runtime/api/runtime_api.dart b/moor/lib/src/runtime/api/runtime_api.dart index 6b6aa370..8163986a 100644 --- a/moor/lib/src/runtime/api/runtime_api.dart +++ b/moor/lib/src/runtime/api/runtime_api.dart @@ -4,12 +4,13 @@ import 'package:meta/meta.dart'; import 'package:moor/moor.dart'; import 'package:moor/src/runtime/executor/delayed_stream_queries.dart'; import 'package:moor/src/runtime/executor/stream_queries.dart'; +import 'package:moor/src/runtime/executor/transactions.dart'; part 'batch.dart'; part 'connection.dart'; +part 'connection_user.dart'; part 'db_base.dart'; part 'dao_base.dart'; -part 'query_engine.dart'; part 'stream_updates.dart'; /// Defines additional runtime behavior for moor. Changing the fields of this diff --git a/moor/lib/src/runtime/executor/helpers/delegates.dart b/moor/lib/src/runtime/executor/helpers/delegates.dart index 4c340de8..4ab5d298 100644 --- a/moor/lib/src/runtime/executor/helpers/delegates.dart +++ b/moor/lib/src/runtime/executor/helpers/delegates.dart @@ -152,7 +152,7 @@ abstract class SupportedTransactionDelegate extends TransactionDelegate { /// Constant constructor on superclass const SupportedTransactionDelegate(); - /// Start a transaction, which we assume implements [QueryEngine], and call + /// Start a transaction, which we assume implements [QueryDelegate], and call /// [run] with the transaction. /// /// If [run] completes with an error, rollback. Otherwise, commit. diff --git a/moor/lib/src/runtime/executor/transactions.dart b/moor/lib/src/runtime/executor/transactions.dart index 92b4edbf..f31cd325 100644 --- a/moor/lib/src/runtime/executor/transactions.dart +++ b/moor/lib/src/runtime/executor/transactions.dart @@ -1,15 +1,11 @@ +import 'package:meta/meta.dart'; import 'package:moor/moor.dart'; import 'package:moor/src/runtime/executor/stream_queries.dart'; /// Runs multiple statements transactionally. -/// -/// Moor users should use [QueryEngine.transaction] to use this api. -@Deprecated( - "This class will be private in moor 4. If you're using this class directly, " - 'please describe your usage in https://github.com/simolus3/moor/issues/810.', -) -class Transaction extends DatabaseConnectionUser with QueryEngine { - final QueryEngine _parent; +@internal +class Transaction extends DatabaseConnectionUser { + final DatabaseConnectionUser _parent; @override GeneratedDatabase get attachedDatabase => _parent.attachedDatabase; @@ -91,18 +87,15 @@ class _TransactionStreamStore extends StreamQueryStore { /// /// To use this api, moor users should use the [MigrationStrategy.beforeOpen] /// parameter inside the [GeneratedDatabase.migration] getter. -@Deprecated( - "This class will be private in moor 4. If you're using this class directly, " - 'please describe your usage in https://github.com/simolus3/moor/issues/810.', -) -class BeforeOpenRunner extends DatabaseConnectionUser with QueryEngine { - final QueryEngine _parent; +@internal +class BeforeOpenRunner extends DatabaseConnectionUser { + final DatabaseConnectionUser _parent; @override GeneratedDatabase get attachedDatabase => _parent.attachedDatabase; - /// Creates a [BeforeOpenRunner] from a [QueryEngine] and the special - /// [executor] running the queries. + /// Creates a [BeforeOpenRunner] from a [DatabaseConnectionUser] and the + /// special [executor] running the queries. BeforeOpenRunner(this._parent, QueryExecutor executor) : super.delegate(_parent, executor: executor); } diff --git a/moor/lib/src/runtime/query_builder/generation_context.dart b/moor/lib/src/runtime/query_builder/generation_context.dart index a63e73d6..aab774e3 100644 --- a/moor/lib/src/runtime/query_builder/generation_context.dart +++ b/moor/lib/src/runtime/query_builder/generation_context.dart @@ -15,8 +15,9 @@ class GenerationContext { /// The [SqlDialect] that should be respected when generating the query. final SqlDialect dialect; - /// The actual [QueryEngine] that's going to execute the generated query. - final QueryEngine? executor; + /// The actual [DatabaseConnectionUser] that's going to execute the generated + /// query. + final DatabaseConnectionUser? executor; final List _boundVariables = []; diff --git a/moor/lib/src/runtime/query_builder/statements/delete.dart b/moor/lib/src/runtime/query_builder/statements/delete.dart index d9fbf2fb..12db6c42 100644 --- a/moor/lib/src/runtime/query_builder/statements/delete.dart +++ b/moor/lib/src/runtime/query_builder/statements/delete.dart @@ -3,8 +3,9 @@ part of '../query_builder.dart'; /// A `DELETE` statement in sql class DeleteStatement extends Query with SingleTableQueryMixin { - /// This constructor should be called by [QueryEngine.delete] for you. - DeleteStatement(QueryEngine database, TableInfo table) + /// This constructor should be called by [DatabaseConnectionUser.delete] for + /// you. + DeleteStatement(DatabaseConnectionUser database, TableInfo table) : super(database, table); @override diff --git a/moor/lib/src/runtime/query_builder/statements/insert.dart b/moor/lib/src/runtime/query_builder/statements/insert.dart index 5f8b9f14..a7a914ef 100644 --- a/moor/lib/src/runtime/query_builder/statements/insert.dart +++ b/moor/lib/src/runtime/query_builder/statements/insert.dart @@ -4,7 +4,7 @@ part of '../query_builder.dart'; class InsertStatement { /// The database to use then executing this statement @protected - final QueryEngine database; + final DatabaseConnectionUser database; /// The table we're inserting into @protected diff --git a/moor/lib/src/runtime/query_builder/statements/query.dart b/moor/lib/src/runtime/query_builder/statements/query.dart index f3c9b89e..ffd6c360 100644 --- a/moor/lib/src/runtime/query_builder/statements/query.dart +++ b/moor/lib/src/runtime/query_builder/statements/query.dart @@ -5,13 +5,13 @@ part of '../query_builder.dart'; abstract class Query { /// The database this statement should be sent to. @protected - QueryEngine database; + DatabaseConnectionUser database; /// The (main) table this query operates on. TableInfo table; /// Used internally by moor. Users should use the appropriate methods on - /// [QueryEngine] instead. + /// [DatabaseConnectionUser] instead. Query(this.database, this.table); /// The `WHERE` clause for this statement @@ -205,7 +205,7 @@ mixin SingleTableQueryMixin /// - The docs on [expressions](https://moor.simonbinder.eu/docs/getting-started/expressions/), /// which explains how to express most SQL expressions in Dart. /// If you want to remove duplicate rows from a query, use the `distinct` - /// parameter on [QueryEngine.select]. + /// parameter on [DatabaseConnectionUser.select]. void where(Expression Function(T tbl) filter) { final predicate = filter(table.asDslTable); diff --git a/moor/lib/src/runtime/query_builder/statements/select/custom_select.dart b/moor/lib/src/runtime/query_builder/statements/select/custom_select.dart index 883f578d..d31915ab 100644 --- a/moor/lib/src/runtime/query_builder/statements/select/custom_select.dart +++ b/moor/lib/src/runtime/query_builder/statements/select/custom_select.dart @@ -14,7 +14,7 @@ class CustomSelectStatement with Selectable { /// The variables for the prepared statement, in the order they appear in /// [query]. Variables are denoted using a question mark in the query. final List variables; - final QueryEngine _db; + final DatabaseConnectionUser _db; /// Constructs a new custom select statement for the query, the variables, /// the affected tables and the database. @@ -65,7 +65,7 @@ class QueryRow { /// it's stored in the database. To read a value, use any of the [read] /// methods. final Map data; - final QueryEngine _db; + final DatabaseConnectionUser _db; /// Construct a row from the raw data and the query engine that maps the raw /// response to appropriate dart types. diff --git a/moor/lib/src/runtime/query_builder/statements/select/select.dart b/moor/lib/src/runtime/query_builder/statements/select/select.dart index 0fc53246..ea1e6e90 100644 --- a/moor/lib/src/runtime/query_builder/statements/select/select.dart +++ b/moor/lib/src/runtime/query_builder/statements/select/select.dart @@ -12,9 +12,9 @@ class SimpleSelectStatement /// `SELECT DISTINCT` statement in sql). Defaults to false. final bool distinct; - /// Used internally by moor, users will want to call [QueryEngine.select] - /// instead. - SimpleSelectStatement(QueryEngine database, TableInfo table, + /// Used internally by moor, users will want to call + /// [DatabaseConnectionUser.select] instead. + SimpleSelectStatement(DatabaseConnectionUser database, TableInfo table, {this.distinct = false}) : super(database, table); diff --git a/moor/lib/src/runtime/query_builder/statements/select/select_with_join.dart b/moor/lib/src/runtime/query_builder/statements/select/select_with_join.dart index 70b259f9..8749f9b3 100644 --- a/moor/lib/src/runtime/query_builder/statements/select/select_with_join.dart +++ b/moor/lib/src/runtime/query_builder/statements/select/select_with_join.dart @@ -9,8 +9,8 @@ class JoinedSelectStatement with LimitContainerMixin, Selectable { /// Used internally by moor, users should use [SimpleSelectStatement.join] /// instead. - JoinedSelectStatement( - QueryEngine database, TableInfo table, this._joins, + JoinedSelectStatement(DatabaseConnectionUser database, + TableInfo table, this._joins, [this.distinct = false, this._includeMainTableInResult = true]) : super(database, table); diff --git a/moor/lib/src/runtime/query_builder/statements/update.dart b/moor/lib/src/runtime/query_builder/statements/update.dart index 9f2bc5fa..83ec9a66 100644 --- a/moor/lib/src/runtime/query_builder/statements/update.dart +++ b/moor/lib/src/runtime/query_builder/statements/update.dart @@ -4,7 +4,7 @@ part of '../query_builder.dart'; class UpdateStatement extends Query with SingleTableQueryMixin { /// Used internally by moor, construct an update statement - UpdateStatement(QueryEngine database, TableInfo table) + UpdateStatement(DatabaseConnectionUser database, TableInfo table) : super(database, table); late Map _updatedFields;