From 0698c16009ef8874bc6a0942e8fa6db1669be751 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sat, 9 Oct 2021 20:08:42 +0200 Subject: [PATCH] Remove references to moor in pkg:drift --- drift/lib/extensions/native.dart | 23 ++++----- drift/lib/isolate.dart | 31 ++++++------ drift/lib/native.dart | 6 ++- drift/lib/remote.dart | 8 ++-- drift/lib/sqlite_keywords.dart | 2 +- drift/lib/src/dsl/columns.dart | 14 +++--- drift/lib/src/dsl/database.dart | 48 ++++++++++--------- drift/lib/src/dsl/table.dart | 22 ++++----- drift/lib/src/ffi/database.dart | 26 +++++----- drift/lib/src/ffi/database_tracker.dart | 4 +- ...i_functions.dart => native_functions.dart} | 4 +- drift/lib/src/isolate.dart | 4 +- drift/lib/src/remote/client_impl.dart | 18 +++---- drift/lib/src/remote/communication.dart | 10 ++-- drift/lib/src/remote/protocol.dart | 6 +-- drift/lib/src/remote/server_impl.dart | 8 ++-- drift/lib/src/runtime/api/batch.dart | 4 +- drift/lib/src/runtime/api/connection.dart | 8 ++-- .../lib/src/runtime/api/connection_user.dart | 32 ++++++------- drift/lib/src/runtime/api/dao_base.dart | 4 +- drift/lib/src/runtime/api/db_base.dart | 12 ++--- drift/lib/src/runtime/api/runtime_api.dart | 4 +- drift/lib/src/runtime/api/stream_updates.dart | 2 +- drift/lib/src/runtime/cancellation_zone.dart | 2 +- drift/lib/src/runtime/data_class.dart | 8 ++-- drift/lib/src/runtime/data_verification.dart | 20 ++++---- drift/lib/src/runtime/exceptions.dart | 14 +++--- .../src/runtime/executor/connection_pool.dart | 2 +- .../executor/delayed_stream_queries.dart | 2 +- drift/lib/src/runtime/executor/executor.dart | 12 ++--- .../runtime/executor/helpers/delegates.dart | 18 +++---- .../src/runtime/executor/helpers/engines.dart | 18 +++---- .../src/runtime/executor/stream_queries.dart | 4 +- .../src/runtime/executor/transactions.dart | 2 +- .../query_builder/components/join.dart | 14 +++--- .../query_builder/expressions/aggregate.dart | 20 ++++---- .../query_builder/expressions/datetimes.dart | 2 +- .../query_builder/expressions/expression.dart | 10 ++-- .../query_builder/expressions/text.dart | 7 +-- .../src/runtime/query_builder/migration.dart | 26 +++++----- .../runtime/query_builder/query_builder.dart | 2 +- .../query_builder/schema/column_impl.dart | 16 ++----- .../query_builder/schema/entities.dart | 8 ++-- .../query_builder/schema/table_info.dart | 14 +++--- .../query_builder/statements/insert.dart | 4 +- .../query_builder/statements/query.dart | 30 ++++++------ .../statements/select/custom_select.dart | 2 +- .../statements/select/select.dart | 10 ++-- .../statements/select/select_with_join.dart | 10 ++-- .../query_builder/statements/update.dart | 6 +-- drift/lib/src/runtime/types/custom_type.dart | 2 +- drift/lib/src/runtime/types/type_system.dart | 2 +- drift/lib/src/web/sql_js.dart | 12 ++--- drift/lib/src/web/storage.dart | 4 +- drift/lib/src/web/web_db.dart | 4 +- drift/lib/web.dart | 6 +-- drift/test/data/tables/custom_tables.dart | 2 +- .../data/tables/{tables.moor => tables.drift} | 0 .../connection_pool_integration_test.dart | 2 +- drift/test/expressions/null_check_test.dart | 9 ++-- drift/test/ffi/close_existing_test.dart | 2 +- drift/test/ffi/moor_functions_test.dart | 4 +- .../integration_tests/moor_files_test.dart | 4 +- drift/test/isolate_test.dart | 24 +++++----- drift/test/streams_test.dart | 2 +- drift/test/types/datetime_test.dart | 4 +- drift/test/types/real_type_test.dart | 4 +- 67 files changed, 334 insertions(+), 336 deletions(-) rename drift/lib/src/ffi/{moor_ffi_functions.dart => native_functions.dart} (98%) rename drift/test/data/tables/{tables.moor => tables.drift} (100%) diff --git a/drift/lib/extensions/native.dart b/drift/lib/extensions/native.dart index 169b303b..02e5b729 100644 --- a/drift/lib/extensions/native.dart +++ b/drift/lib/extensions/native.dart @@ -11,7 +11,7 @@ import '../drift.dart'; /// This function is equivalent to [pow], except that it evaluates to null /// instead of `NaN`. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlPow(Expression base, Expression exponent) { return FunctionCallExpression('pow', [base, exponent]); } @@ -21,7 +21,7 @@ Expression sqlPow(Expression base, Expression exponent) { /// This function is equivalent to [sqrt], except that it returns null instead /// of `NaN` for negative values. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlSqrt(Expression value) { return FunctionCallExpression('sqrt', [value]); } @@ -30,7 +30,7 @@ Expression sqlSqrt(Expression value) { /// /// This function is equivalent to [sin]. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlSin(Expression value) { return FunctionCallExpression('sin', [value]); } @@ -39,7 +39,7 @@ Expression sqlSin(Expression value) { /// /// This function is equivalent to [sin]. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlCos(Expression value) { return FunctionCallExpression('cos', [value]); } @@ -48,7 +48,7 @@ Expression sqlCos(Expression value) { /// /// This function is equivalent to [tan]. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlTan(Expression value) { return FunctionCallExpression('tan', [value]); } @@ -58,7 +58,7 @@ Expression sqlTan(Expression value) { /// This function is equivalent to [asin], except that it evaluates to null /// instead of `NaN`. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlAsin(Expression value) { return FunctionCallExpression('asin', [value]); } @@ -68,7 +68,7 @@ Expression sqlAsin(Expression value) { /// This function is equivalent to [acos], except that it evaluates to null /// instead of `NaN`. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlAcos(Expression value) { return FunctionCallExpression('acos', [value]); } @@ -78,14 +78,14 @@ Expression sqlAcos(Expression value) { /// This function is equivalent to [atan], except that it evaluates to null /// instead of `NaN`. /// -/// This function is only available when using `moor_ffi`. +/// This function is only available when using a `NativeDatabase`. Expression sqlAtan(Expression value) { return FunctionCallExpression('atan', [value]); } /// Adds functionality to string expressions that only work when using -/// `moor_ffi`. -extension MoorFfiSpecificStringExtensions on Expression { +/// a `NativeDatabase`. +extension DriftNativeStringExtensions on Expression { /// Version of `contains` that allows controlling case sensitivity better. /// /// The default `contains` method uses sqlite's `LIKE`, which is case- @@ -100,9 +100,6 @@ extension MoorFfiSpecificStringExtensions on Expression { /// Note that, while Dart has better support for an international alphabet, /// it can still yield unexpected results like the /// [Turkish İ Problem](https://haacked.com/archive/2012/07/05/turkish-i-problem-and-why-you-should-care.aspx/) - /// - /// Note that this is only available when using `moor_ffi` version 0.6.0 or - /// greater. Expression containsCase(String substring, {bool caseSensitive = false}) { return FunctionCallExpression('moor_contains', [ diff --git a/drift/lib/isolate.dart b/drift/lib/isolate.dart index d19d96e0..a84815c4 100644 --- a/drift/lib/isolate.dart +++ b/drift/lib/isolate.dart @@ -1,5 +1,6 @@ -/// Contains utils to run moor databases in a background isolate. This API is -/// not supported on the web. +/// Contains utils to run drift databases in a background isolate. +/// +/// Please note that this API is not supported on the web. library isolate; import 'dart:isolate'; @@ -13,14 +14,14 @@ import 'src/isolate.dart'; /// Signature of a function that opens a database connection. typedef DatabaseOpener = DatabaseConnection Function(); -/// Defines utilities to run moor in a background isolate. In the operation mode -/// created by these utilities, there's a single background isolate doing all -/// the work. Any other isolate can use the [connect] method to obtain an +/// Defines utilities to run drift in a background isolate. In the operation +/// mode created by these utilities, there's a single background isolate doing +/// all the work. Any other isolate can use the [connect] method to obtain an /// instance of a [GeneratedDatabase] class that will delegate its work onto a /// background isolate. Auto-updating queries, and transactions work across /// isolates, and the user facing api is exactly the same. /// -/// Please note that, while running moor in a background isolate can reduce +/// Please note that, while running drift in a background isolate can reduce /// latency in foreground isolates (thus reducing UI lags), the overall /// performance is going to be much worse as data has to be serialized and /// deserialized to be sent over isolates. @@ -28,7 +29,7 @@ typedef DatabaseOpener = DatabaseConnection Function(); /// /// See also: /// - [Isolate], for general information on multi threading in Dart. -/// - The [detailed documentation](https://moor.simonbinder.eu/docs/advanced-features/isolates), +/// - The [detailed documentation](https://drift.simonbinder.eu/docs/advanced-features/isolates), /// which provides example codes on how to use this api. class DriftIsolate { /// The underlying port used to establish a connection with this @@ -43,7 +44,7 @@ class DriftIsolate { DriftIsolate.fromConnectPort(this.connectPort); StreamChannel _open() { - final receive = ReceivePort('moor client receive'); + final receive = ReceivePort('drift client receive'); connectPort.send(receive.sendPort); final controller = @@ -65,7 +66,7 @@ class DriftIsolate { /// /// All operations on the returned [DatabaseConnection] will be executed on a /// background isolate. Setting the [isolateDebugLog] is only helpful when - /// debugging moor itself. + /// debugging drift itself. // todo: breaking: Make synchronous in drift 5 Future connect({bool isolateDebugLog = false}) async { return remote(_open(), debugLog: isolateDebugLog); @@ -94,7 +95,7 @@ class DriftIsolate { final receiveServer = ReceivePort(); final keyFuture = receiveServer.first; - await Isolate.spawn(_startMoorIsolate, [receiveServer.sendPort, opener]); + await Isolate.spawn(_startDriftIsolate, [receiveServer.sendPort, opener]); final key = await keyFuture as SendPort; return DriftIsolate.fromConnectPort(key); } @@ -109,23 +110,23 @@ class DriftIsolate { /// to call [DriftIsolate.inCurrent] will be killed. factory DriftIsolate.inCurrent(DatabaseOpener opener, {bool killIsolateWhenDone = false}) { - final server = RunningMoorServer(Isolate.current, opener(), + final server = RunningDriftServer(Isolate.current, opener(), killIsolateWhenDone: killIsolateWhenDone); return DriftIsolate.fromConnectPort(server.portToOpenConnection); } } -/// Creates a [RunningMoorServer] and sends a [SendPort] that can be used to +/// Creates a [RunningDriftServer] and sends a [SendPort] that can be used to /// establish connections. /// /// Te [args] list must contain two elements. The first one is the [SendPort] -/// that [_startMoorIsolate] will use to send the new [SendPort] used to +/// that [_startDriftIsolate] will use to send the new [SendPort] used to /// establish further connections. The second element is a [DatabaseOpener] /// used to open the underlying database connection. -void _startMoorIsolate(List args) { +void _startDriftIsolate(List args) { final sendPort = args[0] as SendPort; final opener = args[1] as DatabaseOpener; - final server = RunningMoorServer(Isolate.current, opener()); + final server = RunningDriftServer(Isolate.current, opener()); sendPort.send(server.portToOpenConnection); } diff --git a/drift/lib/native.dart b/drift/lib/native.dart index 582d9bfd..01c25aef 100644 --- a/drift/lib/native.dart +++ b/drift/lib/native.dart @@ -1,11 +1,13 @@ -/// Moor implementation using `package:sqlite3/`. +/// A drift database implementation built on `package:sqlite3/`. +/// +/// The [NativeDatabase] class uses `dart:ffi` to access `sqlite3` APIs. /// /// When using a [NativeDatabase], you need to ensure that `sqlite3` is /// available when running your app. For mobile Flutter apps, you can simply /// depend on the `sqlite3_flutter_libs` package to ship the latest sqlite3 /// version with your app. /// For more information other platforms, see [other engines](https://drift.simonbinder.eu/docs/other-engines/vm/). -library moor.ffi; +library drift.ffi; import 'src/ffi/database.dart'; diff --git a/drift/lib/remote.dart b/drift/lib/remote.dart index 3032d8f4..11623e13 100644 --- a/drift/lib/remote.dart +++ b/drift/lib/remote.dart @@ -28,7 +28,7 @@ /// However, note that drift might encode a `List` as `Uint8List`. For /// performance reasons, channel implementations should preserve this. /// -/// Moor assumes full control over the [StreamChannel]s it manages. For this +/// Drift assumes full control over the [StreamChannel]s it manages. For this /// reason, do not send your own messages over them or close them prematurely. /// If you need further channels over the same underlying connection, consider a /// [MultiChannel] instead. @@ -88,7 +88,7 @@ abstract class DriftServer { /// Starts processing requests from the [channel]. /// /// The [channel] uses a drift-internal protocol to serialize database - /// requests. Moor assumes full control over the [channel]. Manually sending + /// requests. Drift assumes full control over the [channel]. Manually sending /// messages over it, or closing it prematurely, can disrupt the server. /// /// __Warning__: As long as this library is marked experimental, the protocol @@ -115,7 +115,7 @@ abstract class DriftServer { /// messages. DatabaseConnection remote(StreamChannel channel, {bool debugLog = false}) { - final client = MoorClient(channel, debugLog); + final client = DriftClient(channel, debugLog); return client.connection; } @@ -125,6 +125,6 @@ DatabaseConnection remote(StreamChannel channel, /// [DriftServer.serve] for this setup to work. /// Also, the [DriftServer] must have been configured to allow remote-shutdowns. Future shutdown(StreamChannel channel) { - final comm = MoorCommunication(channel); + final comm = DriftCommunication(channel); return comm.request(NoArgsRequest.terminateAll); } diff --git a/drift/lib/sqlite_keywords.dart b/drift/lib/sqlite_keywords.dart index 086c97cd..b9d1a94a 100644 --- a/drift/lib/sqlite_keywords.dart +++ b/drift/lib/sqlite_keywords.dart @@ -2,7 +2,7 @@ library drift.sqlite_keywords; /// Contains a set of all sqlite keywords, according to -/// https://www.sqlite.org/lang_keywords.html. Moor will use this list to +/// https://www.sqlite.org/lang_keywords.html. Drift will use this list to /// escape keywords. const sqliteKeywords = { 'ADD', diff --git a/drift/lib/src/dsl/columns.dart b/drift/lib/src/dsl/columns.dart index fb9daeba..6fca651d 100644 --- a/drift/lib/src/dsl/columns.dart +++ b/drift/lib/src/dsl/columns.dart @@ -38,12 +38,12 @@ typedef RealColumn = Column; /// A column builder is used to specify which columns should appear in a table. /// All of the methods defined in this class and its subclasses are not meant to -/// be called at runtime. Instead, moor_generator will take a look at your +/// be called at runtime. Instead, the generator will take a look at your /// source code (specifically, it will analyze which of the methods you use) to /// figure out the column structure of a table. class ColumnBuilder {} -/// DSL extension to define a column with moor. +/// DSL extension to define a column inside a drift table. extension BuildColumn on ColumnBuilder { /// By default, the field name will be used as the column name, e.g. /// `IntColumn get id = integer()` will have "id" as its associated name. @@ -62,7 +62,7 @@ extension BuildColumn on ColumnBuilder { /// primary key. Columns are non-null by default. ColumnBuilder nullable() => _isGenerated(); - /// Tells moor to write a custom constraint after this column definition when + /// Tells drift to write a custom constraint after this column definition when /// writing this column, for instance in a CREATE TABLE statement. /// /// When no custom constraint is set, columns will be written like this: @@ -78,9 +78,9 @@ extension BuildColumn on ColumnBuilder { /// nullability information is lost - you'll have to include it in /// [constraint] if that is desired. /// - /// This can be used to implement constraints that moor does not (yet) + /// This can be used to implement constraints that drift does not (yet) /// support (e.g. unique keys, etc.). If you've found a common use-case for - /// this, it should be considered a limitation of moor itself. Please feel + /// this, it should be considered a limitation of drift itself. Please feel /// free to open an issue at https://github.com/simolus3/moor/issues/new to /// report that. /// @@ -178,7 +178,7 @@ extension BuildColumn on ColumnBuilder { _isGenerated(); /// Turns this column builder into a column. This method won't actually be - /// called in your code. Instead, moor_generator will take a look at your + /// called in your code. Instead, the generator will take a look at your /// source code to figure out your table structure. Column call() => _isGenerated(); } @@ -227,7 +227,7 @@ class JsonKey { /// for [JsonKey] for details. final String key; - /// An annotation to tell moor how the name of a column should appear in + /// An annotation to tell drift how the name of a column should appear in /// generated json. See the documentation for [JsonKey] for details. const JsonKey(this.key); } diff --git a/drift/lib/src/dsl/database.dart b/drift/lib/src/dsl/database.dart index 649e20e2..f80e5462 100644 --- a/drift/lib/src/dsl/database.dart +++ b/drift/lib/src/dsl/database.dart @@ -1,14 +1,14 @@ part of 'dsl.dart'; -/// Use this class as an annotation to inform moor_generator that a database +/// Use this class as an annotation to inform the generator that a database /// class should be generated using the specified [DriftDatabase.tables]. /// /// To write a database class, first annotate an empty class with /// [DriftDatabase] and run the build runner using /// `dart pub run build_runner build`. -/// Moor will have generated a class that has the same name as your database +/// Drift 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 [QueryExecutor] to use moor: +/// a [QueryExecutor] to use drift: /// ```dart /// class MyDatabase extends _$MyDatabase { // _$MyDatabase was generated /// MyDatabase(): @@ -27,33 +27,34 @@ class DriftDatabase { /// [DriftAccessor]. final List daos; - /// {@template moor_compile_queries_param} - /// Optionally, a list of named sql queries. During a build, moor will look at - /// the defined sql, figure out what they do, and write appropriate + /// {@template drift_compile_queries_param} + /// Optionally, a list of named sql queries. During a build, drift will look + /// at the defined sql, figure out what they do, and write appropriate /// methods in your generated database. /// /// For instance, when using /// ```dart - /// @UseMoor( + /// @DriftDatabase( /// tables: [Users], /// queries: { /// 'userById': 'SELECT * FROM users WHERE id = ?', /// }, /// ) /// ``` - /// Moor will generate two methods for you: `userById(int id)` and + /// Drift will generate two methods for you: `userById(int id)` and /// `watchUserById(int id)`. /// {@endtemplate} final Map queries; - /// {@template moor_include_param} - /// Defines the `.moor` files to include when building the table structure for - /// this database. For details on how to integrate `.moor` files into your - /// Dart code, see [the documentation](https://moor.simonbinder.eu/docs/using-sql/custom_tables/). + /// {@template drift_compile_queries_param} + /// + /// Defines the `.drift` files to include when building the table structure + /// for this database. For details on how to integrate `.drift` files into + /// your Dart code, see [the documentation](https://drift.simonbinder.eu/docs/using-sql/custom_tables/). /// {@endtemplate} final Set include; - /// Use this class as an annotation to inform moor_generator that a database + /// Use this class as an annotation to inform the generator that a database /// class should be generated using the specified [DriftDatabase.tables]. const DriftDatabase({ this.tables = const [], @@ -77,7 +78,7 @@ class DriftDatabase { /// MyDao(MyDatabase db) : super(db); /// } /// ``` -/// After having run the build step once more, moor will have generated a mixin +/// After having run the build step once more, drift will have generated a mixin /// called `_$MyDaoMixin`. Change your class definition to /// `class MyDao extends DatabaseAccessor with _$MyDaoMixin` and /// you're ready to make queries inside your dao. You can obtain an instance of @@ -85,21 +86,22 @@ class DriftDatabase { /// class. /// /// See also: -/// - https://moor.simonbinder.eu/daos/ +/// - https://drift.simonbinder.eu/daos/ class DriftAccessor { /// The tables accessed by this DAO. final List tables; - /// {@macro moor_compile_queries_param} + /// {@macro drift_compile_queries_param} final Map queries; - /// {@macro moor_include_param} + /// {@macro drift_include_param} final Set include; - /// Annotation for a class to declare it as an dao. See [UseDao] and the - /// referenced documentation on how to use daos with moor. - const DriftAccessor( - {this.tables = const [], - this.queries = const {}, - this.include = const {}}); + /// Annotation for a class to declare it as an dao. See [DriftAccessor] and + /// the referenced documentation on how to use daos with drift. + const DriftAccessor({ + this.tables = const [], + this.queries = const {}, + this.include = const {}, + }); } diff --git a/drift/lib/src/dsl/table.dart b/drift/lib/src/dsl/table.dart index 5126c49b..6046abf8 100644 --- a/drift/lib/src/dsl/table.dart +++ b/drift/lib/src/dsl/table.dart @@ -6,12 +6,12 @@ abstract class HasResultSet { const HasResultSet(); } -/// Subclasses represent a table in a database generated by moor. +/// Subclasses represent a table in a database generated by drift. abstract class Table extends HasResultSet { - /// Defines a table to be used with moor. + /// Defines a table to be used with drift. const Table(); - /// The sql table name to be used. By default, moor will use the snake_case + /// The sql table name to be used. By default, drift will use the snake_case /// representation of your class name as the sql table name. For instance, a /// [Table] class named `LocalSettings` will be called `local_settings` by /// default. @@ -27,7 +27,7 @@ abstract class Table extends HasResultSet { /// statement. This is intended to be used by generated code only. bool get withoutRowId => false; - /// Moor will write some table constraints automatically, for instance when + /// Drift will write some table constraints automatically, for instance when /// you override [primaryKey]. You can turn this behavior off if you want to. /// This is intended to be used by generated code only. bool get dontWriteConstraints => false; @@ -45,10 +45,10 @@ abstract class Table extends HasResultSet { ///} /// ``` /// The getter must return a set literal using the `=>` syntax so that the - /// moor generator can understand the code. + /// drift generator can understand the code. /// Also, please note that it's an error to have an /// [BuildIntColumn.autoIncrement] column and a custom primary key. - /// As an auto-incremented `IntColumn` is recognized by moor to be the + /// As an auto-incremented `IntColumn` is recognized by drift to be the /// primary key, doing so will result in an exception thrown at runtime. @visibleForOverriding Set? get primaryKey => null; @@ -121,8 +121,8 @@ abstract class Table extends HasResultSet { /// A class to be used as an annotation on [Table] classes to customize the /// name for the data class that will be generated for the table class. The data /// class is a dart object that will be used to represent a row in the table. -/// {@template moor_custom_data_class} -/// By default, moor will attempt to use the singular form of the table name +/// {@template drift_custom_data_class} +/// By default, drift will attempt to use the singular form of the table name /// when naming data classes (e.g. a table named "Users" will generate a data /// class called "User"). However, this doesn't work for irregular plurals and /// you might want to choose a different name, for which this annotation can be @@ -131,11 +131,11 @@ abstract class Table extends HasResultSet { @Target({TargetKind.classType}) class DataClassName { /// The overridden name to use when generating the data class for a table. - /// {@macro moor_custom_data_class} + /// {@macro drift_custom_data_class} final String name; /// Customize the data class name for a given table. - /// {@macro moor_custom_data_class} + /// {@macro drift_custom_data_class} const DataClassName(this.name); } @@ -155,7 +155,7 @@ class UseRowClass { /// used to map database rows to the desired row class. final String constructor; - /// Customize the class used by moor to hold an instance of an annotated + /// Customize the class used by drift to hold an instance of an annotated /// table. /// /// For details, see the overall documentation on [UseRowClass]. diff --git a/drift/lib/src/ffi/database.dart b/drift/lib/src/ffi/database.dart index 2e4b1d50..5e95aa6b 100644 --- a/drift/lib/src/ffi/database.dart +++ b/drift/lib/src/ffi/database.dart @@ -5,16 +5,16 @@ import 'package:sqlite3/sqlite3.dart'; import '../../backends.dart'; import 'database_tracker.dart'; -import 'moor_ffi_functions.dart'; +import 'native_functions.dart'; /// Signature of a function that can perform setup work on a [database] before -/// moor is fully ready. +/// drift is fully ready. /// /// This could be used to, for instance, set encryption keys for SQLCipher /// implementations. typedef DatabaseSetup = void Function(Database database); -/// A moor database implementation based on `dart:ffi`, running directly in a +/// A drift database implementation based on `dart:ffi`, running directly in a /// Dart VM or an AOT compiled Dart/Flutter application. class NativeDatabase extends DelegatedDatabase { NativeDatabase._(DatabaseDelegate delegate, bool logStatements) @@ -23,11 +23,11 @@ class NativeDatabase extends DelegatedDatabase { /// Creates a database that will store its result in the [file], creating it /// if it doesn't exist. /// - /// {@template moor_vm_database_factory} + /// {@template drift_vm_database_factory} /// If [logStatements] is true (defaults to `false`), generated sql statements /// will be printed before executing. This can be useful for debugging. /// The optional [setup] function can be used to perform a setup just after - /// the database is opened, before moor is fully ready. This can be used to + /// the database is opened, before drift is fully ready. This can be used to /// add custom user-defined sql functions or to provide encryption keys in /// SQLCipher implementations. /// {@endtemplate} @@ -38,13 +38,13 @@ class NativeDatabase extends DelegatedDatabase { /// Creates an in-memory database won't persist its changes on disk. /// - /// {@macro moor_vm_database_factory} + /// {@macro drift_vm_database_factory} factory NativeDatabase.memory( {bool logStatements = false, DatabaseSetup? setup}) { return NativeDatabase._(_VmDelegate(null, setup), logStatements); } - /// Creates a moor executor for an opened [database] from the `sqlite3` + /// Creates a drift executor for an opened [database] from the `sqlite3` /// package. /// /// When the [closeUnderlyingOnClose] argument is set (which is the default), @@ -52,10 +52,10 @@ class NativeDatabase extends DelegatedDatabase { /// [Database.dispose] the [database] passed to this constructor. /// /// Using [NativeDatabase.opened] may be useful when you want to use the same - /// underlying [Database] in multiple moor connections. Moor uses this - /// internally when running [integration tests for migrations](https://moor.simonbinder.eu/docs/advanced-features/migrations/#verifying-migrations). + /// underlying [Database] in multiple drift connections. Drift uses this + /// internally when running [integration tests for migrations](https://drift.simonbinder.eu/docs/advanced-features/migrations/#verifying-migrations). /// - /// {@macro moor_vm_database_factory} + /// {@macro drift_vm_database_factory} factory NativeDatabase.opened(Database database, {bool logStatements = false, DatabaseSetup? setup, @@ -81,7 +81,7 @@ class NativeDatabase extends DelegatedDatabase { /// it's not necessary to call [closeExistingInstances]. However, features /// like hot (stateless) restart can make it impossible to reliably close /// every database. In that case, we leak native sqlite3 database connections - /// that aren't referenced by any Dart object. Moor can track those + /// that aren't referenced by any Dart object. Drift can track those /// connections across Dart VM restarts by storing them in an in-memory sqlite /// database. /// Calling this method can cleanup resources and database locks after a @@ -94,7 +94,7 @@ class NativeDatabase extends DelegatedDatabase { /// aren't any active [NativeDatabase]s, not even on another isolate. /// /// A suitable place to call [closeExistingInstances] is at an early stage - /// of your `main` method, before you're using moor. + /// of your `main` method, before you're using drift. /// /// ```dart /// void main() { @@ -174,7 +174,7 @@ class _VmDelegate extends DatabaseDelegate { } void _initializeDatabase() { - _db.useMoorVersions(); + _db.useNativeFunctions(); setup?.call(_db); versionDelegate = _VmVersionDelegate(_db); } diff --git a/drift/lib/src/ffi/database_tracker.dart b/drift/lib/src/ffi/database_tracker.dart index 97a5df7a..2a48e99b 100644 --- a/drift/lib/src/ffi/database_tracker.dart +++ b/drift/lib/src/ffi/database_tracker.dart @@ -19,7 +19,7 @@ import 'package:sqlite3/sqlite3.dart'; /// `VmDatabase.closeExistingInstances()` to release those resources. final DatabaseTracker tracker = DatabaseTracker(); -/// Internal class that we don't export to moor users. See [tracker] for why +/// Internal class that we don't export to drift users. See [tracker] for why /// this is necessary. class DatabaseTracker { final Database _db; @@ -27,7 +27,7 @@ class DatabaseTracker { /// Creates a new tracker with necessary tables. DatabaseTracker() : _db = sqlite3.open( - 'file:moor_connection_store?mode=memory&cache=shared', + 'file:drift_connection_store?mode=memory&cache=shared', uri: true, ) { _db.execute(''' diff --git a/drift/lib/src/ffi/moor_ffi_functions.dart b/drift/lib/src/ffi/native_functions.dart similarity index 98% rename from drift/lib/src/ffi/moor_ffi_functions.dart rename to drift/lib/src/ffi/native_functions.dart index 0a2971da..f799d3fc 100644 --- a/drift/lib/src/ffi/moor_ffi_functions.dart +++ b/drift/lib/src/ffi/native_functions.dart @@ -5,9 +5,9 @@ import 'package:sqlite3/sqlite3.dart'; // ignore_for_file: avoid_returning_null, only_throw_errors /// Extension to register moor-specific sql functions. -extension EnableMoorFunctions on Database { +extension EnableNativeFunctions on Database { /// Enables moor-specific sql functions on this database. - void useMoorVersions() { + void useNativeFunctions() { createFunction( functionName: 'power', deterministic: true, diff --git a/drift/lib/src/isolate.dart b/drift/lib/src/isolate.dart index f1d413c0..820e1b7c 100644 --- a/drift/lib/src/isolate.dart +++ b/drift/lib/src/isolate.dart @@ -11,7 +11,7 @@ import '../remote.dart'; // ignore_for_file: public_member_api_docs @internal -class RunningMoorServer { +class RunningDriftServer { final Isolate self; final bool killIsolateWhenDone; @@ -21,7 +21,7 @@ class RunningMoorServer { SendPort get portToOpenConnection => connectPort.sendPort; - RunningMoorServer(this.self, DatabaseConnection connection, + RunningDriftServer(this.self, DatabaseConnection connection, {this.killIsolateWhenDone = true}) : server = DriftServer(connection, allowRemoteShutdown: true) { final subscription = connectPort.listen((message) { diff --git a/drift/lib/src/remote/client_impl.dart b/drift/lib/src/remote/client_impl.dart index 97a00743..4d49cc13 100644 --- a/drift/lib/src/remote/client_impl.dart +++ b/drift/lib/src/remote/client_impl.dart @@ -10,9 +10,9 @@ import '../runtime/cancellation_zone.dart'; import 'communication.dart'; import 'protocol.dart'; -/// The client part of a remote moor communication scheme. -class MoorClient { - final MoorCommunication _channel; +/// The client part of a remote drift communication scheme. +class DriftClient { + final DriftCommunication _channel; late final _RemoteStreamQueryStore _streamStore = _RemoteStreamQueryStore(this); @@ -28,8 +28,8 @@ class MoorClient { late QueryExecutorUser _connectedDb; /// Starts relaying database operations over the request channel. - MoorClient(StreamChannel channel, bool debugLog) - : _channel = MoorCommunication(channel, debugLog) { + DriftClient(StreamChannel channel, bool debugLog) + : _channel = DriftCommunication(channel, debugLog) { _channel.setRequestHandler(_handleRequest); } @@ -46,7 +46,7 @@ class MoorClient { } abstract class _BaseExecutor extends QueryExecutor { - final MoorClient client; + final DriftClient client; int? _executorId; _BaseExecutor(this.client, [this._executorId]); @@ -110,7 +110,7 @@ abstract class _BaseExecutor extends QueryExecutor { } class _RemoteQueryExecutor extends _BaseExecutor { - _RemoteQueryExecutor(MoorClient client, [int? executorId]) + _RemoteQueryExecutor(DriftClient client, [int? executorId]) : super(client, executorId); Completer? _setSchemaVersion; @@ -147,7 +147,7 @@ class _RemoteTransactionExecutor extends _BaseExecutor implements TransactionExecutor { final int? _outerExecutorId; - _RemoteTransactionExecutor(MoorClient client, this._outerExecutorId) + _RemoteTransactionExecutor(DriftClient client, this._outerExecutorId) : super(client); Completer? _pendingOpen; @@ -200,7 +200,7 @@ class _RemoteTransactionExecutor extends _BaseExecutor } class _RemoteStreamQueryStore extends StreamQueryStore { - final MoorClient _client; + final DriftClient _client; final Set _awaitingUpdates = {}; _RemoteStreamQueryStore(this._client); diff --git a/drift/lib/src/remote/communication.dart b/drift/lib/src/remote/communication.dart index 372817cb..e596ae19 100644 --- a/drift/lib/src/remote/communication.dart +++ b/drift/lib/src/remote/communication.dart @@ -8,15 +8,15 @@ import 'protocol.dart'; /// Wrapper around a two-way communication channel to support requests and /// responses. -class MoorCommunication { - static const _protocol = MoorProtocol(); +class DriftCommunication { + static const _protocol = DriftProtocol(); final StreamChannel _channel; final bool _debugLog; StreamSubscription? _inputSubscription; - // note that there are two MoorCommunication instances in each connection, + // note that there are two DriftCommunication instances in each connection, // (one per remote). Each of them has an independent _currentRequestId field int _currentRequestId = 0; final Completer _closeCompleter = Completer(); @@ -24,8 +24,8 @@ class MoorCommunication { final StreamController _incomingRequests = StreamController(sync: true); - /// Starts a moor communication channel over a raw [StreamChannel]. - MoorCommunication(this._channel, [this._debugLog = false]) { + /// Starts a drift communication channel over a raw [StreamChannel]. + DriftCommunication(this._channel, [this._debugLog = false]) { _inputSubscription = _channel.stream.listen( _handleMessage, onDone: _closeCompleter.complete, diff --git a/drift/lib/src/remote/protocol.dart b/drift/lib/src/remote/protocol.dart index 05a935e9..3dfac8b9 100644 --- a/drift/lib/src/remote/protocol.dart +++ b/drift/lib/src/remote/protocol.dart @@ -1,10 +1,10 @@ -// This is a moor-internal file +// This is a drift-internal file // ignore_for_file: constant_identifier_names, public_member_api_docs import 'package:drift/drift.dart'; -class MoorProtocol { - const MoorProtocol(); +class DriftProtocol { + const DriftProtocol(); static const _tag_Request = 0; static const _tag_Response_success = 1; diff --git a/drift/lib/src/remote/server_impl.dart b/drift/lib/src/remote/server_impl.dart index 8ca378c5..e5ccd39e 100644 --- a/drift/lib/src/remote/server_impl.dart +++ b/drift/lib/src/remote/server_impl.dart @@ -8,7 +8,7 @@ import '../runtime/cancellation_zone.dart'; import 'communication.dart'; import 'protocol.dart'; -/// The implementation of a moor server, manging remote channels to send +/// The implementation of a drift server, manging remote channels to send /// database requests. class ServerImplementation implements DriftServer { /// The Underlying database connection that will be used. @@ -36,7 +36,7 @@ class ServerImplementation implements DriftServer { late final _ServerDbUser _dbUser = _ServerDbUser(this); bool _isShuttingDown = false; - final Set _activeChannels = {}; + final Set _activeChannels = {}; final Completer _done = Completer(); /// Creates a server from the underlying connection and further options. @@ -51,7 +51,7 @@ class ServerImplementation implements DriftServer { throw StateError('Cannot add new channels after shutdown() was called'); } - final comm = MoorCommunication(channel)..setRequestHandler(_handleRequest); + final comm = DriftCommunication(channel)..setRequestHandler(_handleRequest); _activeChannels.add(comm); comm.closed.then((_) => _activeChannels.remove(comm)); } @@ -66,7 +66,7 @@ class ServerImplementation implements DriftServer { return done; } - MoorCommunication? get _anyClient { + DriftCommunication? get _anyClient { final iterator = _activeChannels.iterator; if (iterator.moveNext()) { return iterator.current; diff --git a/drift/lib/src/runtime/api/batch.dart b/drift/lib/src/runtime/api/batch.dart index b0df5466..adc0b02e 100644 --- a/drift/lib/src/runtime/api/batch.dart +++ b/drift/lib/src/runtime/api/batch.dart @@ -77,8 +77,8 @@ class Batch { /// Writes all present columns from the [row] into all rows in the [table] /// that match the [where] clause. /// - /// For more details on how updates work in moor, check out - /// [UpdateStatement.write] or the [documentation with examples](https://moor.simonbinder.eu/docs/getting-started/writing_queries/#updates-and-deletes) + /// For more details on how updates work in drift, check out + /// [UpdateStatement.write] or the [documentation with examples](https://drift.simonbinder.eu/docs/getting-started/writing_queries/#updates-and-deletes) void update(TableInfo table, Insertable row, {Expression Function(T table)? where}) { _addUpdate(table, UpdateKind.update); diff --git a/drift/lib/src/runtime/api/connection.dart b/drift/lib/src/runtime/api/connection.dart index 28e44eb1..148e57a1 100644 --- a/drift/lib/src/runtime/api/connection.dart +++ b/drift/lib/src/runtime/api/connection.dart @@ -1,6 +1,6 @@ part of 'runtime_api.dart'; -/// A database connection managed by moor. Contains three components: +/// A database connection managed by drift. Contains three components: /// - a [SqlTypeSystem], which is responsible to map between Dart types and /// values understood by the database engine. /// - a [QueryExecutor], which runs sql commands @@ -32,14 +32,14 @@ class DatabaseConnection { /// /// This can be useful in scenarios where you need to obtain a database /// instance synchronously, but need an async setup. A prime example here is - /// `MoorIsolate`: + /// `DriftIsolate`: /// /// ```dart - /// @UseMoor(...) + /// @DriftDatabase(...) /// class MyDatabase extends _$MyDatabase { /// MyDatabase._connect(DatabaseConnection c): super.connect(c); /// - /// factory MyDatabase.fromIsolate(MoorIsolate isolate) { + /// factory MyDatabase.fromIsolate(DriftDatabase isolate) { /// return MyDatabase._connect( /// // isolate.connect() returns a future, but we can still return a /// // database synchronously thanks to DatabaseConnection.delayed! diff --git a/drift/lib/src/runtime/api/connection_user.dart b/drift/lib/src/runtime/api/connection_user.dart index b3f41fc3..e89a3c98 100644 --- a/drift/lib/src/runtime/api/connection_user.dart +++ b/drift/lib/src/runtime/api/connection_user.dart @@ -77,9 +77,9 @@ abstract class DatabaseConnectionUser { /// A, potentially more specific, database engine based on the [Zone] context. /// - /// Inside a [transaction] block, moor will replace this [resolvedEngine] with - /// an engine specific to the transaction. All other methods on this class - /// implicitly use the [resolvedEngine] to run their SQL statements. + /// Inside a [transaction] block, drift will replace this [resolvedEngine] + /// with an engine specific to the transaction. All other methods on this + /// class implicitly use the [resolvedEngine] to run their SQL statements. /// This let's users call methods on their top-level database or dao class /// but run them in a transaction-specific executor. @internal @@ -92,8 +92,8 @@ abstract class DatabaseConnectionUser { /// In response to calling this method, all streams listening on any of the /// [tables] will load their data again. /// - /// Primarily, this method is meant to be used by moor-internal code. Higher- - /// level moor APIs will call this method to dispatch stream updates. + /// Primarily, this method is meant to be used by drift-internal code. Higher- + /// level drift APIs will call this method to dispatch stream updates. /// Of course, you can also call it yourself to manually dispatch table /// updates. To obtain a [TableInfo], use the corresponding getter on the /// database class. @@ -106,7 +106,7 @@ abstract class DatabaseConnectionUser { /// Dispatches the set of [updates] to the stream query manager. /// /// This method is more specific than [markTablesUpdated] in the presence of - /// triggers or foreign key constraints. Moor needs to support both when + /// triggers or foreign key constraints. Drift needs to support both when /// calculating which streams to update. For instance, consider a simple /// database with two tables (`a` and `b`) and a trigger inserting into `b` /// after a delete on `a`). @@ -149,7 +149,7 @@ abstract class DatabaseConnectionUser { /// already ready. /// /// Calling this method directly might circumvent the current transaction. For - /// that reason, it should only be called inside moor. + /// that reason, it should only be called inside drift. Future doWhenOpened(FutureOr Function(QueryExecutor e) fn) { return executor.ensureOpen(attachedDatabase).then((_) => fn(executor)); } @@ -169,7 +169,7 @@ abstract class DatabaseConnectionUser { /// Starts a query on the given table. /// - /// In moor, queries are commonly used as a builder by chaining calls on them + /// In drift, queries are commonly used as a builder by chaining calls on them /// using the `..` syntax from Dart. For instance, to load the 10 oldest users /// with an 'S' in their name, you could use: /// ```dart @@ -190,7 +190,7 @@ abstract class DatabaseConnectionUser { /// duplicate rows from the result set. /// /// For more information on queries, see the - /// [documentation](https://moor.simonbinder.eu/docs/getting-started/writing_queries/). + /// [documentation](https://drift.simonbinder.eu/docs/getting-started/writing_queries/). SimpleSelectStatement select( ResultSetImplementation table, {bool distinct = false}) { @@ -226,8 +226,8 @@ abstract class DatabaseConnectionUser { /// For simple queries, use [select]. /// /// See also: - /// - the documentation on [aggregate expressions](https://moor.simonbinder.eu/docs/getting-started/expressions/#aggregate) - /// - the documentation on [group by](https://moor.simonbinder.eu/docs/advanced-features/joins/#group-by) + /// - the documentation on [aggregate expressions](https://drift.simonbinder.eu/docs/getting-started/expressions/#aggregate) + /// - the documentation on [group by](https://drift.simonbinder.eu/docs/advanced-features/joins/#group-by) JoinedSelectStatement selectOnly( ResultSetImplementation table, { bool distinct = false, @@ -238,7 +238,7 @@ abstract class DatabaseConnectionUser { /// Starts a [DeleteStatement] that can be used to delete rows from a table. /// - /// See the [documentation](https://moor.simonbinder.eu/docs/getting-started/writing_queries/#updates-and-deletes) + /// See the [documentation](https://drift.simonbinder.eu/docs/getting-started/writing_queries/#updates-and-deletes) /// for more details and example on how delete statements work. DeleteStatement delete(TableInfo table) { return DeleteStatement(resolvedEngine, table); @@ -246,7 +246,7 @@ abstract class DatabaseConnectionUser { /// Executes a custom delete or update statement and returns the amount of /// rows that have been changed. - /// You can use the [updates] parameter so that moor knows which tables are + /// You can use the [updates] parameter so that drift knows which tables are /// affected by your query. All select streams that depend on a table /// specified there will then update their data. For more accurate results, /// you can also set the [updateKind] parameter to [UpdateKind.delete] or @@ -271,7 +271,7 @@ abstract class DatabaseConnectionUser { /// Executes a custom insert statement and returns the last inserted rowid. /// - /// You can tell moor which tables your query is going to affect by using the + /// You can tell drift which tables your query is going to affect by using the /// [updates] parameter. Query-streams running on any of these tables will /// then be re-run. Future customInsert(String query, @@ -289,7 +289,7 @@ abstract class DatabaseConnectionUser { /// Runs a `INSERT`, `UPDATE` or `DELETE` statement returning rows. /// - /// You can use the [updates] parameter so that moor knows which tables are + /// You can use the [updates] parameter so that drift knows which tables are /// affected by your query. All select streams that depend on a table /// specified there will then update their data. For more accurate results, /// you can also set the [updateKind] parameter. @@ -399,7 +399,7 @@ abstract class DatabaseConnectionUser { /// transaction inside a transaction returns the parent transaction. /// /// See also: - /// - the docs on [transactions](https://moor.simonbinder.eu/docs/transactions/) + /// - the docs on [transactions](https://drift.simonbinder.eu/docs/transactions/) Future transaction(Future Function() action) async { final resolved = resolvedEngine; if (resolved is Transaction) { diff --git a/drift/lib/src/runtime/api/dao_base.dart b/drift/lib/src/runtime/api/dao_base.dart index 6e62755e..cf840f78 100644 --- a/drift/lib/src/runtime/api/dao_base.dart +++ b/drift/lib/src/runtime/api/dao_base.dart @@ -13,12 +13,12 @@ abstract class DatabaseAccessor @override final T attachedDatabase; - /// Used internally by moor + /// Used internally by drift DatabaseAccessor(this.attachedDatabase) : super.delegate(attachedDatabase); } /// Extension for generated dao classes to keep the old [db] field that was -/// renamed to [DatabaseAccessor.attachedDatabase] in moor 3.0 +/// renamed to [DatabaseAccessor.attachedDatabase] in drift 3.0 extension OldDbFieldInDatabaseAccessor on DatabaseAccessor { /// The generated database that this dao is attached to. diff --git a/drift/lib/src/runtime/api/db_base.dart b/drift/lib/src/runtime/api/db_base.dart index 489f9a22..f2ce294d 100644 --- a/drift/lib/src/runtime/api/db_base.dart +++ b/drift/lib/src/runtime/api/db_base.dart @@ -2,7 +2,7 @@ part of 'runtime_api.dart'; /// Keep track of how many databases have been opened for a given database /// type. -/// We get a number of error reports of "moor not generating tables" that have +/// We get a number of error reports of "drift not generating tables" that have /// their origin in users opening multiple instances of their database. This /// can cause a race conditions when the second [GeneratedDatabase] is opening a /// underlying [DatabaseConnection] that is already opened but doesn't have the @@ -32,7 +32,7 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser /// The collection of update rules contains information on how updates on /// tables result in other updates, for instance due to a trigger. /// - /// There should be no need to overwrite this field, moor will generate an + /// There should be no need to overwrite this field, drift will generate an /// appropriate implementation automatically. StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules.none(); @@ -76,13 +76,13 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser _openedDbCount[runtimeType] = _openedDbCount[runtimeType]! + 1; if (count > 1) { driftRuntimeOptions.debugPrint( - 'WARNING (moor): It looks like you\'ve created the database class ' + 'WARNING (drift): It looks like you\'ve created the database class ' '$runtimeType multiple times. When these two databases use the same ' 'QueryExecutor, race conditions will occur and might corrupt the ' 'database. \n' - 'Try to follow the advice at https://moor.simonbinder.eu/faq/#using-the-database ' + 'Try to follow the advice at https://drift.simonbinder.eu/faq/#using-the-database ' 'or, if you know what you\'re doing, set ' - 'moorRuntimeOptions.dontWarnAboutMultipleDatabases = true\n' + 'driftRuntimeOptions.dontWarnAboutMultipleDatabases = true\n' 'Here is the stacktrace from when the database was opened a second ' 'time:\n${StackTrace.current}\n' 'This warning will only appear on debug builds.', @@ -95,7 +95,7 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser /// Creates a [Migrator] with the provided query executor. Migrators generate /// sql statements to create or drop tables. /// - /// This api is mainly used internally in moor, especially to implement the + /// This api is mainly used internally in drift, especially to implement the /// [beforeOpen] callback from the database site. /// However, it can also be used if you need to create tables manually and /// outside of a [MigrationStrategy]. For almost all use cases, overriding diff --git a/drift/lib/src/runtime/api/runtime_api.dart b/drift/lib/src/runtime/api/runtime_api.dart index e5832bea..ad4c22a8 100644 --- a/drift/lib/src/runtime/api/runtime_api.dart +++ b/drift/lib/src/runtime/api/runtime_api.dart @@ -13,7 +13,7 @@ part 'dao_base.dart'; part 'db_base.dart'; part 'stream_updates.dart'; -/// Defines additional runtime behavior for moor. Changing the fields of this +/// Defines additional runtime behavior for drift. Changing the fields of this /// class is rarely necessary. class DriftRuntimeOptions { /// Don't warn when a database class isn't used as singleton. @@ -22,7 +22,7 @@ class DriftRuntimeOptions { /// The [ValueSerializer] that will be used by default in [DataClass.toJson]. ValueSerializer defaultSerializer = const ValueSerializer.defaults(); - /// The function used by moor to emit debug prints. + /// The function used by drift to emit debug prints. /// /// This is the function used with `logStatements: true` on databases and /// `debugLog` on isolates. diff --git a/drift/lib/src/runtime/api/stream_updates.dart b/drift/lib/src/runtime/api/stream_updates.dart index cd9c4319..787c73cb 100644 --- a/drift/lib/src/runtime/api/stream_updates.dart +++ b/drift/lib/src/runtime/api/stream_updates.dart @@ -50,7 +50,7 @@ abstract class UpdateRule { /// /// An update on [on] implicitly triggers updates on [result]. /// -/// This class is for use by generated or moor-internal code only. It does not +/// This class is for use by generated or drift-internal code only. It does not /// adhere to Semantic Versioning and should not be used manually. class WritePropagation extends UpdateRule { /// The updates that cause further writes in [result]. diff --git a/drift/lib/src/runtime/cancellation_zone.dart b/drift/lib/src/runtime/cancellation_zone.dart index 37172df9..79c8d033 100644 --- a/drift/lib/src/runtime/cancellation_zone.dart +++ b/drift/lib/src/runtime/cancellation_zone.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:meta/meta.dart'; -const _key = #moor.runtime.cancellation; +const _key = #drift.runtime.cancellation; /// Runs an asynchronous operation with support for cancellations. /// diff --git a/drift/lib/src/runtime/data_class.dart b/drift/lib/src/runtime/data_class.dart index 6ad76a5b..5acff306 100644 --- a/drift/lib/src/runtime/data_class.dart +++ b/drift/lib/src/runtime/data_class.dart @@ -22,7 +22,7 @@ abstract class Insertable { Map toColumns(bool nullToAbsent); } -/// A common supertype for all data classes generated by moor. Data classes are +/// A common supertype for all data classes generated by drift. Data classes are /// immutable structures that represent a single row in a database table. abstract class DataClass { /// Constant constructor so that generated data classes can be constant. @@ -123,8 +123,8 @@ class RawValuesInsertable implements Insertable { /// As you can see, a simple `int?` does not provide enough information to /// distinguish between the three cases. A `null` value could mean that the /// column is absent, or that it should explicitly be set to `null`. -/// For this reason, moor introduces the [Value] wrapper to make the distinction -/// explicit. +/// For this reason, drift introduces the [Value] wrapper to make the +/// distinction explicit. class Value { /// Whether this [Value] wrapper contains a present [value] that should be /// inserted or updated. @@ -186,7 +186,7 @@ abstract class ValueSerializer { /// This serializer won't transform numbers or strings. Date times will be /// encoded as a unix-timestamp. /// - /// To override the default serializer moor uses, you can change the + /// To override the default serializer drift uses, you can change the /// [DriftRuntimeOptions.defaultSerializer] field. const factory ValueSerializer.defaults() = _DefaultValueSerializer; diff --git a/drift/lib/src/runtime/data_verification.dart b/drift/lib/src/runtime/data_verification.dart index 2e850022..fb082063 100644 --- a/drift/lib/src/runtime/data_verification.dart +++ b/drift/lib/src/runtime/data_verification.dart @@ -6,7 +6,7 @@ class VerificationMeta { /// The dart getter name of the property being validated. final String dartGetterName; - /// Used internally by moor + /// Used internally by drift const VerificationMeta(this.dartGetterName); } @@ -20,23 +20,23 @@ class VerificationResult { /// wrong. final String? message; - /// Used internally by moor + /// Used internally by drift const VerificationResult(this.success, this.message); - /// Used internally by moor + /// Used internally by drift const VerificationResult.success() : success = true, message = null; - /// Used internally by moor + /// Used internally by drift const VerificationResult.failure(this.message) : success = false; } -/// Used internally by moor for integrity checks. +/// Used internally by drift for integrity checks. class VerificationContext { final Map _errors; - /// Used internally by moor + /// Used internally by drift bool get dataValid => _errors.isEmpty; /// Creates a verification context, which stores the individual integrity @@ -44,23 +44,23 @@ class VerificationContext { VerificationContext() : _errors = {}; /// Constructs a verification context that can't be used to report errors. - /// This is used internally by moor if integrity checks have been disabled. + /// This is used internally by drift if integrity checks have been disabled. const VerificationContext.notEnabled() : _errors = const {}; - /// Used internally by moor when inserting + /// Used internally by drift when inserting void handle(VerificationMeta meta, VerificationResult result) { if (!result.success) { _errors[meta] = result; } } - /// Used internally by moor + /// Used internally by drift void missing(VerificationMeta meta) { _errors[meta] = const VerificationResult.failure( "This value was required, but isn't present"); } - /// Used internally by moor + /// Used internally by drift void throwIfInvalid(dynamic dataObject) { if (dataValid) return; diff --git a/drift/lib/src/runtime/exceptions.dart b/drift/lib/src/runtime/exceptions.dart index 4d61fe41..4fa238d6 100644 --- a/drift/lib/src/runtime/exceptions.dart +++ b/drift/lib/src/runtime/exceptions.dart @@ -18,19 +18,19 @@ class InvalidDataException implements Exception { } /// A wrapper class for internal exceptions thrown by the underlying database -/// engine when moor can give additional context or help. +/// engine when drift can give additional context or help. /// /// For instance, when we know that an invalid statement has been constructed, /// we catch the database exception and try to explain why that has happened. class DriftWrappedException implements Exception { /// Contains a possible description of why the underlying [cause] occurred, - /// for instance because a moor api was misused. + /// for instance because a drift api was misused. final String message; - /// The underlying exception caught by moor + /// The underlying exception caught by drift final Object? cause; - /// The original stacktrace when caught by moor + /// The original stacktrace when caught by drift final StackTrace? trace; /// Creates a new [DriftWrappedException] to provide additional details about @@ -40,15 +40,15 @@ class DriftWrappedException implements Exception { @override String toString() { return '$cause at \n$trace\n' - 'Moor detected a possible cause for this: $message'; + 'Drift detected a possible cause for this: $message'; } } -/// Exception thrown by moor when rolling back a transaction fails. +/// Exception thrown by drift when rolling back a transaction fails. /// /// When using a `transaction` block, transactions are automatically rolled back /// when the inner block throws an exception. -/// If sending the `ROLLBACK TRANSACTION` command fails as well, moor reports +/// If sending the `ROLLBACK TRANSACTION` command fails as well, drift reports /// both that and the initial error with a [CouldNotRollBackException]. class CouldNotRollBackException implements Exception { /// The original exception that caused the transaction to be rolled back. diff --git a/drift/lib/src/runtime/executor/connection_pool.dart b/drift/lib/src/runtime/executor/connection_pool.dart index fd6477db..970b93a6 100644 --- a/drift/lib/src/runtime/executor/connection_pool.dart +++ b/drift/lib/src/runtime/executor/connection_pool.dart @@ -1,7 +1,7 @@ import 'package:drift/backends.dart'; import 'package:drift/drift.dart'; -/// A query executor for moor that delegates work to multiple executors. +/// A query executor for drift that delegates work to multiple executors. abstract class MultiExecutor extends QueryExecutor { /// Creates a query executor that will delegate work to different executors. /// diff --git a/drift/lib/src/runtime/executor/delayed_stream_queries.dart b/drift/lib/src/runtime/executor/delayed_stream_queries.dart index 1aac364c..78c3425e 100644 --- a/drift/lib/src/runtime/executor/delayed_stream_queries.dart +++ b/drift/lib/src/runtime/executor/delayed_stream_queries.dart @@ -5,7 +5,7 @@ import 'stream_queries.dart'; /// Version of [StreamQueryStore] that delegates work to an asynchronously- /// available delegate. -/// This class is internal and should not be exposed to moor users. It's used +/// This class is internal and should not be exposed to drift users. It's used /// through a delayed database connection. @internal class DelayedStreamQueryStore implements StreamQueryStore { diff --git a/drift/lib/src/runtime/executor/executor.dart b/drift/lib/src/runtime/executor/executor.dart index 03076be9..045c1bb9 100644 --- a/drift/lib/src/runtime/executor/executor.dart +++ b/drift/lib/src/runtime/executor/executor.dart @@ -7,11 +7,11 @@ import 'package:drift/drift.dart' show OpeningDetails; /// A query executor is responsible for executing statements on a database and /// return their results in a raw form. /// -/// This is an internal api of moor, which can break often. If you want to +/// This is an internal api of drift, which can break often. If you want to /// implement custom database backends, consider using the new `backends` API. -/// The [moor_flutter implementation](https://github.com/simolus3/moor/blob/develop/moor_flutter/lib/moor_flutter.dart) +/// The [NativeDatabase implementation](https://github.com/simolus3/moor/blob/develop/drift/lib/src/ffi/database.dart) /// might be useful as a reference. If you want to write your own database -/// engine to use with moor and run into issues, please consider creating an +/// engine to use with drift and run into issues, please consider creating an /// issue. abstract class QueryExecutor { /// The [SqlDialect] to use for this database engine. @@ -42,8 +42,8 @@ abstract class QueryExecutor { /// Prepares and runs [statements]. /// - /// Running them doesn't need to happen in a transaction. When using moor's - /// batch api, moor will call this method from a transaction either way. This + /// Running them doesn't need to happen in a transaction. When using drift's + /// batch api, drift will call this method from a transaction either way. This /// method mainly exists to save duplicate parsing costs, allowing each /// statement to be prepared only once. Future runBatched(BatchedStatements statements); @@ -120,7 +120,7 @@ class ArgumentsForBatchedStatement { /// Bound arguments for the referenced statement. final List arguments; - /// Used internally by moor. + /// Used internally by drift. ArgumentsForBatchedStatement(this.statementIndex, this.arguments); @override diff --git a/drift/lib/src/runtime/executor/helpers/delegates.dart b/drift/lib/src/runtime/executor/helpers/delegates.dart index 31421f43..96aae339 100644 --- a/drift/lib/src/runtime/executor/helpers/delegates.dart +++ b/drift/lib/src/runtime/executor/helpers/delegates.dart @@ -28,7 +28,7 @@ abstract class DatabaseDelegate extends QueryDelegate { /// MySql server we connect to) /// - [OnOpenVersionDelegate] for databases whose schema version can only be /// set while opening it (such as sqflite) - /// - [DynamicVersionDelegate] for databases where moor can set the schema + /// - [DynamicVersionDelegate] for databases where drift can set the schema /// version at any time (used for the web and VM implementation) DbVersionDelegate get versionDelegate; @@ -37,17 +37,17 @@ abstract class DatabaseDelegate extends QueryDelegate { /// A future that completes with `true` when this database is open and with /// `false` when its not. The future may never complete with an error or with - /// null. It should return relatively quickly, as moor queries it before each + /// null. It should return relatively quickly, as drift queries it before each /// statement it sends to the database. FutureOr get isOpen; - /// Opens the database. Moor will only call this when [isOpen] has returned - /// false before. Further, moor will not attempt to open a database multiple + /// Opens the database. Drift will only call this when [isOpen] has returned + /// false before. Further, drift will not attempt to open a database multiple /// times, so you don't have to worry about a connection being created /// multiple times. /// /// The [QueryExecutorUser] is the user-defined database annotated with - /// [UseMoor]. It might be useful to read the + /// [DriftDatabase]. It might be useful to read the /// [QueryExecutorUser.schemaVersion] if that information is required while /// opening the database. Future open(QueryExecutorUser db); @@ -58,7 +58,7 @@ abstract class DatabaseDelegate extends QueryDelegate { // default no-op implementation } - /// Callback from moor after the database has been fully opened and all + /// Callback from drift after the database has been fully opened and all /// migrations ran. void notifyDatabaseOpened(OpeningDetails details) { // default no-op @@ -122,9 +122,9 @@ abstract class TransactionDelegate { } /// A [TransactionDelegate] for database APIs which don't already support -/// creating transactions. Moor will send a `BEGIN TRANSACTION` statement at the -/// beginning, then block the database, and finally send a `COMMIT` statement -/// at the end. +/// creating transactions. Drift will send a `BEGIN TRANSACTION` statement at +/// the beginning, then block the database, and finally send a `COMMIT` +/// statement at the end. class NoTransactionDelegate extends TransactionDelegate { /// The statement that starts a transaction on this database engine. final String start; diff --git a/drift/lib/src/runtime/executor/helpers/engines.dart b/drift/lib/src/runtime/executor/helpers/engines.dart index df2d7437..789c7497 100644 --- a/drift/lib/src/runtime/executor/helpers/engines.dart +++ b/drift/lib/src/runtime/executor/helpers/engines.dart @@ -28,8 +28,8 @@ abstract class _BaseExecutor extends QueryExecutor { throw StateError(''' Tried to run an operation without first calling QueryExecutor.ensureOpen()! -If you're seeing this exception from a moor database, it may indicate a bug in -moor itself. Please consider opening an issue with the stack trace and details +If you're seeing this exception from a drift database, it may indicate a bug in +drift itself. Please consider opening an issue with the stack trace and details on how to reproduce this.'''); } @@ -59,7 +59,7 @@ without awaiting every statement in it.'''); void _log(String sql, List args) { if (logStatements) { - driftRuntimeOptions.debugPrint('Moor: Sent $sql with args $args'); + driftRuntimeOptions.debugPrint('Drift: Sent $sql with args $args'); } } @@ -117,7 +117,7 @@ without awaiting every statement in it.'''); assert(_debugCheckIsOpen()); if (logStatements) { driftRuntimeOptions - .debugPrint('Moor: Executing $statements in a batch'); + .debugPrint('Drift: Executing $statements in a batch'); } return impl.runBatched(statements); }); @@ -352,11 +352,11 @@ class DelegatedDatabase extends _BaseExecutor { } } -/// Inside a `beforeOpen` callback, all moor apis must be available. At the same -/// time, the `beforeOpen` callback must complete before any query sent outside -/// of a `beforeOpen` callback can run. We do this by introducing a special -/// executor that delegates all work to the original executor, but without -/// blocking on `ensureOpen` +/// Inside a `beforeOpen` callback, all drift apis must be available. At the +/// same time, the `beforeOpen` callback must complete before any query sent +/// outside of a `beforeOpen` callback can run. We do this by introducing a +/// special executor that delegates all work to the original executor, but +/// without blocking on `ensureOpen` class _BeforeOpeningExecutor extends _BaseExecutor { final DelegatedDatabase _base; diff --git a/drift/lib/src/runtime/executor/stream_queries.dart b/drift/lib/src/runtime/executor/stream_queries.dart index 00e86bdf..65dab0be 100644 --- a/drift/lib/src/runtime/executor/stream_queries.dart +++ b/drift/lib/src/runtime/executor/stream_queries.dart @@ -10,7 +10,7 @@ import '../cancellation_zone.dart'; const _listEquality = ListEquality(); -// This is an internal moor library that's never exported to users. +// This is an internal drift library that's never exported to users. // ignore_for_file: public_member_api_docs /// Representation of a select statement that knows from which tables the @@ -132,7 +132,7 @@ class StreamQueryStore { // Hey there! If you're sent here because your Flutter tests fail, please // call and await Database.close() in your Flutter widget tests! - // Moor uses timers internally so that after you stopped listening to a + // Drift uses timers internally so that after you stopped listening to a // stream, it can keep its cache just a bit longer. When you listen to // streams a lot, this helps reduce duplicate statements, especially with // Flutter's StreamBuilder. diff --git a/drift/lib/src/runtime/executor/transactions.dart b/drift/lib/src/runtime/executor/transactions.dart index 5b204aa3..0d876c2e 100644 --- a/drift/lib/src/runtime/executor/transactions.dart +++ b/drift/lib/src/runtime/executor/transactions.dart @@ -86,7 +86,7 @@ class _TransactionStreamStore extends StreamQueryStore { /// Special query engine to run the [MigrationStrategy.beforeOpen] callback. /// -/// To use this api, moor users should use the [MigrationStrategy.beforeOpen] +/// To use this api, drift users should use the [MigrationStrategy.beforeOpen] /// parameter inside the [GeneratedDatabase.migration] getter. @internal class BeforeOpenRunner extends DatabaseConnectionUser { diff --git a/drift/lib/src/runtime/query_builder/components/join.dart b/drift/lib/src/runtime/query_builder/components/join.dart index d30df7cd..3745ff2d 100644 --- a/drift/lib/src/runtime/query_builder/components/join.dart +++ b/drift/lib/src/runtime/query_builder/components/join.dart @@ -18,7 +18,7 @@ const Map<_JoinType, String> _joinKeywords = { _JoinType.cross: 'CROSS', }; -/// Used internally by moor when calling [SimpleSelectStatement.join]. +/// Used internally by drift when calling [SimpleSelectStatement.join]. /// /// You should use [innerJoin], [leftOuterJoin] or [crossJoin] to obtain a /// [Join] instance. @@ -61,14 +61,14 @@ class Join extends Component { /// Creates a sql inner join that can be used in [SimpleSelectStatement.join]. /// -/// {@template moor_join_include_results} +/// {@template drift_join_include_results} /// The optional [useColumns] parameter (defaults to true) can be used to /// exclude the [other] table from the result set. When set to false, /// [TypedResult.readTable] will return `null` for that table. /// {@endtemplate} /// /// See also: -/// - https://moor.simonbinder.eu/docs/advanced-features/joins/#joins +/// - https://drift.simonbinder.eu/docs/advanced-features/joins/#joins /// - http://www.sqlitetutorial.net/sqlite-inner-join/ Join innerJoin( ResultSetImplementation other, Expression on, @@ -79,10 +79,10 @@ Join innerJoin( /// Creates a sql left outer join that can be used in /// [SimpleSelectStatement.join]. /// -/// {@macro moor_join_include_results} +/// {@macro drift_join_include_results} /// /// See also: -/// - https://moor.simonbinder.eu/docs/advanced-features/joins/#joins +/// - https://drift.simonbinder.eu/docs/advanced-features/joins/#joins /// - http://www.sqlitetutorial.net/sqlite-left-join/ Join leftOuterJoin( ResultSetImplementation other, Expression on, @@ -93,10 +93,10 @@ Join leftOuterJoin( /// Creates a sql cross join that can be used in /// [SimpleSelectStatement.join]. /// -/// {@macro moor_join_include_results} +/// {@macro drift_join_include_results} /// /// See also: -/// - https://moor.simonbinder.eu/docs/advanced-features/joins/#joins +/// - https://drift.simonbinder.eu/docs/advanced-features/joins/#joins /// - http://www.sqlitetutorial.net/sqlite-cross-join/ Join crossJoin(ResultSetImplementation other, {bool? useColumns}) { diff --git a/drift/lib/src/runtime/query_builder/expressions/aggregate.dart b/drift/lib/src/runtime/query_builder/expressions/aggregate.dart index 3e05f70c..2b1c2086 100644 --- a/drift/lib/src/runtime/query_builder/expressions/aggregate.dart +++ b/drift/lib/src/runtime/query_builder/expressions/aggregate.dart @@ -3,7 +3,7 @@ part of '../query_builder.dart'; /// Returns the amount of rows in the current group matching the optional /// [filter]. /// -/// {@templace moor_aggregate_filter} +/// {@templace drift_aggregate_filter} /// To only consider rows matching a predicate, you can set the optional /// [filter]. Note that [filter] is only available from sqlite 3.30, released on /// 2019-10-04. Most devices will use an older sqlite version. @@ -24,7 +24,7 @@ extension BaseAggregate
on Expression
{ /// /// If [distinct] is set (defaults to false), duplicate values will not be /// counted twice. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression count({bool? distinct, Expression? filter}) { return _AggregateExpression('COUNT', this, filter: filter, distinct: distinct); @@ -53,21 +53,21 @@ extension BaseAggregate
on Expression
{ extension ArithmeticAggregates
on Expression { /// Return the average of all non-null values in this group. /// - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression avg({Expression? filter}) => _AggregateExpression('AVG', this, filter: filter); /// Return the maximum of all non-null values in this group. /// /// If there are no non-null values in the group, returns null. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression max({Expression? filter}) => _AggregateExpression('MAX', this, filter: filter); /// Return the minimum of all non-null values in this group. /// /// If there are no non-null values in the group, returns null. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression min({Expression? filter}) => _AggregateExpression('MIN', this, filter: filter); @@ -79,7 +79,7 @@ extension ArithmeticAggregates
on Expression { /// /// See also [total], which behaves similarly but returns a floating point /// value and doesn't throw an overflow exception. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression sum({Expression? filter}) => _AggregateExpression('SUM', this, filter: filter); @@ -87,7 +87,7 @@ extension ArithmeticAggregates
on Expression { /// /// If all values in the group are null, [total] returns `0.0`. This function /// uses floating-point values internally. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression total({Expression? filter}) => _AggregateExpression('TOTAL', this, filter: filter); } @@ -95,21 +95,21 @@ extension ArithmeticAggregates
on Expression { /// Provides aggregate functions that are available on date time expressions. extension DateTimeAggregate on Expression { /// Return the average of all non-null values in this group. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression avg({Expression? filter}) => secondsSinceEpoch.avg(filter: filter).roundToInt().dartCast(); /// Return the maximum of all non-null values in this group. /// /// If there are no non-null values in the group, returns null. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression max({Expression? filter}) => _AggregateExpression('MAX', this, filter: filter); /// Return the minimum of all non-null values in this group. /// /// If there are no non-null values in the group, returns null. - /// {@macro moor_aggregate_filter} + /// {@macro drift_aggregate_filter} Expression min({Expression? filter}) => _AggregateExpression('MIN', this, filter: filter); } diff --git a/drift/lib/src/runtime/query_builder/expressions/datetimes.dart b/drift/lib/src/runtime/query_builder/expressions/datetimes.dart index 7b4e58be..a773e8ed 100644 --- a/drift/lib/src/runtime/query_builder/expressions/datetimes.dart +++ b/drift/lib/src/runtime/query_builder/expressions/datetimes.dart @@ -49,7 +49,7 @@ extension DateTimeExpressions on Expression { /// Returns an expression containing the amount of seconds from the unix /// epoch (January 1st, 1970) to `this` datetime expression. The datetime is /// assumed to be in utc. - // for moor, date times are just unix timestamps, so we don't need to rewrite + // for drift, date times are just unix timestamps, so we don't need to rewrite // anything when converting Expression get secondsSinceEpoch => dartCast(); diff --git a/drift/lib/src/runtime/query_builder/expressions/expression.dart b/drift/lib/src/runtime/query_builder/expressions/expression.dart index 4b5b3bac..5aba37d1 100644 --- a/drift/lib/src/runtime/query_builder/expressions/expression.dart +++ b/drift/lib/src/runtime/query_builder/expressions/expression.dart @@ -6,7 +6,7 @@ const _equality = ListEquality(); /// /// Most prominently, this includes [Expression]s. /// -/// Used internally by moor. +/// Used internally by drift. abstract class FunctionParameter implements Component {} /// Any sql expression that evaluates to some generic value. This does not @@ -44,14 +44,14 @@ abstract class Expression implements FunctionParameter { /// will __NOT__ generate a `CAST` expression in sql. To generate a `CAST` /// in sql, use [cast]. /// - /// This method is used internally by moor. + /// This method is used internally by drift. Expression dartCast() { return _DartCastExpression(this); } /// Generates a `CAST(expression AS TYPE)` expression. /// - /// Note that this does not do a meaningful conversion for moor-only types + /// Note that this does not do a meaningful conversion for drift-only types /// like `bool` or `DateTime`. Both would simply generate a `CAST AS INT` /// expression. Expression cast() => _CastInSqlExpression(this); @@ -406,9 +406,9 @@ class _CastInSqlExpression extends Expression { /// A sql expression that calls a function. /// -/// This class is mainly used by moor internally. If you find yourself using +/// This class is mainly used by drift internally. If you find yourself using /// this class, consider [creating an issue](https://github.com/simolus3/moor/issues/new) -/// to request native support in moor. +/// to request native support in drift. class FunctionCallExpression extends Expression { /// The name of the function to call final String functionName; diff --git a/drift/lib/src/runtime/query_builder/expressions/text.dart b/drift/lib/src/runtime/query_builder/expressions/text.dart index af717ef6..580ab047 100644 --- a/drift/lib/src/runtime/query_builder/expressions/text.dart +++ b/drift/lib/src/runtime/query_builder/expressions/text.dart @@ -14,8 +14,9 @@ extension StringExpressionOperators on Expression { /// The [multiLine], [caseSensitive], [unicode] and [dotAll] parameters /// correspond to the parameters on [RegExp]. /// - /// Note that this function is only available when using `moor_ffi`. If you - /// need to support the web or `moor_flutter`, consider using [like] instead. + /// Note that this function is only available when using a `NativeDatabase`. + /// If you need to support the web or `moor_flutter`, consider using [like] + /// instead. Expression regexp( String regex, { bool multiLine = false, @@ -23,7 +24,7 @@ extension StringExpressionOperators on Expression { bool unicode = false, bool dotAll = false, }) { - // moor_ffi has a special regexp sql function that takes a third parameter + // We have a special regexp sql function that takes a third parameter // to encode flags. If the least significant bit is set, multiLine is // enabled. The next three bits enable case INSENSITIVITY (it's sensitive // by default), unicode and dotAll. diff --git a/drift/lib/src/runtime/query_builder/migration.dart b/drift/lib/src/runtime/query_builder/migration.dart index 180296a2..e854ddb1 100644 --- a/drift/lib/src/runtime/query_builder/migration.dart +++ b/drift/lib/src/runtime/query_builder/migration.dart @@ -10,13 +10,13 @@ typedef OnCreate = Future Function(Migrator m); typedef OnUpgrade = Future Function(Migrator m, int from, int to); /// Signature of a function that's called before a database is marked opened by -/// moor, but after migrations took place. This is a suitable callback to to +/// drift, but after migrations took place. This is a suitable callback to to /// populate initial data or issue `PRAGMA` statements that you want to use. typedef OnBeforeOpen = Future Function(OpeningDetails details); Future _defaultOnCreate(Migrator m) => m.createAll(); Future _defaultOnUpdate(Migrator m, int from, int to) async => - throw Exception("You've bumped the schema version for your moor database " + throw Exception("You've bumped the schema version for your drift database " "but didn't provide a strategy for schema updates. Please do that by " 'adapting the migrations getter in your database class.'); @@ -50,7 +50,7 @@ class MigrationStrategy { class Migrator { final GeneratedDatabase _db; - /// Used internally by moor when opening the database. + /// Used internally by drift when opening the database. Migrator(this._db); /// Creates all tables specified for the database, if they don't exist @@ -108,8 +108,8 @@ class Migrator { /// /// The [migration] to run describes the transformation to apply to the table. /// The individual fields of the [TableMigration] class contain more - /// information on the transformations supported at the moment. Moor's - /// [documentation][moor docs] also contains more details and examples for + /// information on the transformations supported at the moment. Drifts's + /// [documentation][drift docs] also contains more details and examples for /// common migrations that can be run with [alterTable]. /// /// When deleting columns from a table, make sure to migrate tables that have @@ -119,7 +119,7 @@ class Migrator { /// not reliably handle views at the moment. /// /// [other alter]: https://www.sqlite.org/lang_altertable.html#otheralter - /// [moor docs]: https://moor.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations + /// [drift docs]: https://drift.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations @experimental Future alterTable(TableMigration migration) async { final foreignKeysEnabled = @@ -349,14 +349,14 @@ class Migrator { /// Changes the name of a column in a [table]. /// - /// After renaming a column in a Dart table or a moor file and re-running the + /// After renaming a column in a Dart table or a drift file and re-running the /// generator, you can use [renameColumn] in a migration step to rename the /// column for existing databases. /// /// The [table] argument must be set to the table enclosing the changed /// column. The [oldName] must be set to the old name of the [column] in SQL. - /// For Dart tables, note that moor will transform `camelCase` column names in - /// Dart to `snake_case` column names in SQL. + /// For Dart tables, note that drift will transform `camelCase` column names + /// in Dart to `snake_case` column names in SQL. /// /// __Important compatibility information__: [renameColumn] uses an /// `ALTER TABLE RENAME COLUMN` internally. Support for that syntax was added @@ -378,7 +378,7 @@ class Migrator { /// Changes the [table] name from [oldName] to the current /// [TableInfo.actualTableName]. /// - /// After renaming a table in moor or Dart and re-running the generator, you + /// After renaming a table in drift or Dart and re-running the generator, you /// can use [renameTable] in a migration step to rename the table in existing /// databases. Future renameTable(TableInfo table, String oldName) async { @@ -415,7 +415,7 @@ class OpeningDetails { /// Whether a schema upgrade was performed while opening the database. bool get hadUpgrade => !wasCreated && versionBefore != versionNow; - /// Used internally by moor when opening a database. + /// Used internally by drift when opening a database. const OpeningDetails(this.versionBefore, this.versionNow) // Should use null instead of 0 for consistency : assert(versionBefore != 0); @@ -429,7 +429,7 @@ extension DestructiveMigrationExtension on GeneratedDatabase { /// To use this behavior, override the `migration` getter in your database: /// /// ```dart - /// @UseMoor(...) + /// @DriftDatabase(...) /// class MyDatabase extends _$MyDatabase { /// @override /// MigrationStrategy get migration => destructiveFallback; @@ -457,7 +457,7 @@ extension DestructiveMigrationExtension on GeneratedDatabase { /// Contains instructions needed to run a complex migration on a table, using /// the steps described in [Making other kinds of table schema changes][https://www.sqlite.org/lang_altertable.html#otheralter]. /// -/// For examples and more details, see [the documentation](https://moor.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations). +/// For examples and more details, see [the documentation](https://drift.simonbinder.eu/docs/advanced-features/migrations/#complex-migrations). @experimental class TableMigration { /// The table to migrate. It is assumed that this table already exists at the diff --git a/drift/lib/src/runtime/query_builder/query_builder.dart b/drift/lib/src/runtime/query_builder/query_builder.dart index 6bb1a9d4..5a670a39 100644 --- a/drift/lib/src/runtime/query_builder/query_builder.dart +++ b/drift/lib/src/runtime/query_builder/query_builder.dart @@ -71,7 +71,7 @@ void _writeCommaSeparated( } } -/// An enumeration of database systems supported by moor. Only +/// An enumeration of database systems supported by drift. Only /// [SqlDialect.sqlite] is officially supported, all others are in an /// experimental state at the moment. enum SqlDialect { diff --git a/drift/lib/src/runtime/query_builder/schema/column_impl.dart b/drift/lib/src/runtime/query_builder/schema/column_impl.dart index 41433059..ba0640b5 100644 --- a/drift/lib/src/runtime/query_builder/schema/column_impl.dart +++ b/drift/lib/src/runtime/query_builder/schema/column_impl.dart @@ -15,15 +15,15 @@ class GeneratedColumn extends Column { /// Whether null values are allowed for this column. final bool $nullable; - /// Default constraints generated by moor. + /// Default constraints generated by drift. final String? _defaultConstraints; /// Custom constraints that have been specified for this column. /// /// Some constraints, like `NOT NULL` or checks for booleans, are generated by - /// moor by default. + /// drift by default. /// Constraints can also be overridden with [BuildColumn.customConstraint], - /// in which case the moor constraints will not be applied. + /// in which case the drift constraints will not be applied. final String? $customConstraints; /// The default expression to be used during inserts when no value has been @@ -48,7 +48,7 @@ class GeneratedColumn extends Column { final bool requiredDuringInsert; /// Whether this column has an `AUTOINCREMENT` primary key constraint that was - /// created by moor. + /// created by drift. bool get hasAutoIncrement => _defaultConstraints?.contains('AUTOINCREMENT') == true; @@ -111,7 +111,7 @@ class GeneratedColumn extends Column { if (writeBrackets) into.buffer.write(')'); } - // these custom constraints refer to builtin constraints from moor + // these custom constraints refer to builtin constraints from drift if (_defaultConstraints != null) { into.buffer ..write(' ') @@ -138,12 +138,6 @@ class GeneratedColumn extends Column { /// implementation only checks for nullability, but subclasses might enforce /// additional checks. For instance, a text column might verify that a text /// has a certain length. - /// - /// Note: The behavior of this method was changed in moor 1.5. Before, null - /// values were interpreted as an absent value during updates or if the - /// [defaultValue] is set. Verification was skipped for absent values. - /// This is no longer the case, all null values are assumed to be an sql - /// `NULL`. VerificationResult isAcceptableValue(T value, VerificationMeta meta) { final nullOk = $nullable; if (!nullOk && value == null) { diff --git a/drift/lib/src/runtime/query_builder/schema/entities.dart b/drift/lib/src/runtime/query_builder/schema/entities.dart index 9d84b0dc..0d8c04ad 100644 --- a/drift/lib/src/runtime/query_builder/schema/entities.dart +++ b/drift/lib/src/runtime/query_builder/schema/entities.dart @@ -9,7 +9,7 @@ abstract class DatabaseSchemaEntity { /// A sqlite trigger that's executed before, after or instead of a subset of /// writes on a specific tables. -/// In moor, triggers can only be declared in `.moor` files. +/// In drift, triggers can only be declared in `.drift` files. /// /// For more information on triggers, see the [CREATE TRIGGER][sqlite-docs] /// documentation from sqlite, or the [entry on sqlitetutorial.net][sql-tut]. @@ -49,7 +49,7 @@ class Index extends DatabaseSchemaEntity { /// A sqlite view. /// -/// In moor, views can only be declared in `.moor` files. +/// In drift, views can only be declared in `.drift` files. /// /// For more information on views, see the [CREATE VIEW][sqlite-docs] /// documentation from sqlite, or the [entry on sqlitetutorial.net][sql-tut]. @@ -72,7 +72,7 @@ abstract class View extends ResultSetImplementation /// An internal schema entity to run an sql statement when the database is /// created. /// -/// The generator uses this entity to implement `@create` statements in moor +/// The generator uses this entity to implement `@create` statements in drift /// files: /// ```sql /// CREATE TABLE users (name TEXT); @@ -80,7 +80,7 @@ abstract class View extends ResultSetImplementation /// @create: INSERT INTO users VALUES ('Bob'); /// ``` /// A [OnCreateQuery] is emitted for each `@create` statement in an included -/// moor file. +/// drift file. class OnCreateQuery extends DatabaseSchemaEntity { /// The sql statement that should be run in the default `onCreate` clause. final String sql; diff --git a/drift/lib/src/runtime/query_builder/schema/table_info.dart b/drift/lib/src/runtime/query_builder/schema/table_info.dart index 44252d13..535c12b0 100644 --- a/drift/lib/src/runtime/query_builder/schema/table_info.dart +++ b/drift/lib/src/runtime/query_builder/schema/table_info.dart @@ -2,12 +2,12 @@ part of '../query_builder.dart'; /// Base class for generated table classes. /// -/// Moor generates a subclass of [TableInfo] for each table used in a database. +/// Drift generates a subclass of [TableInfo] for each table used in a database. /// This classes contains information about the table's schema (e.g. its /// [primaryKey] or [$columns]). /// /// [TableDsl] is the original table class written by the user. For tables -/// defined in moor files, this is the table implementation class itself. +/// defined in drift files, this is the table implementation class itself. /// [D] is the type of the data class generated from the table. /// /// To obtain an instance of this class, use a table getter from the database. @@ -97,7 +97,7 @@ mixin TableInfo on Table int get hashCode => Object.hash(aliasedName, actualTableName); } -/// Additional interface for tables in a moor file that have been created with +/// Additional interface for tables in a drift file that have been created with /// an `CREATE VIRTUAL TABLE STATEMENT`. mixin VirtualTableInfo on TableInfo { /// Returns the module name and the arguments that were used in the statement @@ -108,7 +108,7 @@ mixin VirtualTableInfo on TableInfo { /// Static extension members for generated table classes. /// -/// Most of these are accessed internally by moor or by generated code. +/// Most of these are accessed internally by drift or by generated code. extension TableInfoUtils on ResultSetImplementation { /// Like [map], but from a [row] instead of the low-level map. D mapFromRow(QueryRow row, {String? tablePrefix}) { @@ -131,7 +131,7 @@ extension TableInfoUtils on ResultSetImplementation { /// Like [mapFromRow], but maps columns from the result through [alias]. /// - /// This is used internally by moor to support mapping to a table from a + /// This is used internally by drift to support mapping to a table from a /// select statement with different column names. For instance, for: /// /// ```sql @@ -140,7 +140,7 @@ extension TableInfoUtils on ResultSetImplementation { /// query: SELECT foo AS c1, bar AS c2 FROM tbl; /// ``` /// - /// Moor would generate code to call this method with `'c1': 'foo'` and + /// Drift would generate code to call this method with `'c1': 'foo'` and /// `'c2': 'bar'` in [alias]. D mapFromRowWithAlias(QueryRow row, Map alias) { return map({ @@ -158,7 +158,7 @@ extension RowIdExtension on TableInfo { /// column is an _alias_ to the row id in sqlite3. /// /// If the row id has not explicitly been declared as a column aliasing it, - /// the [rowId] will not be part of a moor-generated data class. In this + /// the [rowId] will not be part of a drift-generated data class. In this /// case, the [rowId] getter can be used to refer to a table's row id in a /// query. Expression get rowId { diff --git a/drift/lib/src/runtime/query_builder/statements/insert.dart b/drift/lib/src/runtime/query_builder/statements/insert.dart index 24b68d40..e9487b51 100644 --- a/drift/lib/src/runtime/query_builder/statements/insert.dart +++ b/drift/lib/src/runtime/query_builder/statements/insert.dart @@ -11,7 +11,7 @@ class InsertStatement { final TableInfo table; /// Constructs an insert statement from the database and the table. Used - /// internally by moor. + /// internally by drift. InsertStatement(this.database, this.table); /// Inserts a row constructed from the fields in [entity]. @@ -111,7 +111,7 @@ class InsertStatement { /// Creates a [GenerationContext] which contains the sql necessary to run an /// insert statement fro the [entry] with the [mode]. /// - /// This method is used internally by moor. Consider using [insert] instead. + /// This method is used internally by drift. Consider using [insert] instead. GenerationContext createContext(Insertable entry, InsertMode mode, {UpsertClause? onConflict, bool returning = false}) { _validateIntegrity(entry); diff --git a/drift/lib/src/runtime/query_builder/statements/query.dart b/drift/lib/src/runtime/query_builder/statements/query.dart index 55f79a58..bb5aef52 100644 --- a/drift/lib/src/runtime/query_builder/statements/query.dart +++ b/drift/lib/src/runtime/query_builder/statements/query.dart @@ -10,7 +10,7 @@ abstract class Query extends Component { /// The (main) table or view that this query operates on. ResultSetImplementation table; - /// Used internally by moor. Users should use the appropriate methods on + /// Used internally by drift. Users should use the appropriate methods on /// [DatabaseConnectionUser] instead. Query(this.database, this.table); @@ -57,9 +57,9 @@ abstract class Query extends Component { /// Constructs the query that can then be sent to the database executor. /// - /// This is used internally by moor to run the query. Users should use the - /// other methods explained in the [documentation][moor-docs]. - /// [moor-docs]: https://moor.simonbinder.eu/docs/getting-started/writing_queries/ + /// This is used internally by drift to run the query. Users should use the + /// other methods explained in the [documentation][drift-docs]. + /// [drift-docs]: https://drift.simonbinder.eu/docs/getting-started/writing_queries/ GenerationContext constructQuery() { final ctx = GenerationContext.fromDb(database); writeInto(ctx); @@ -73,7 +73,7 @@ abstract class Query extends Component { /// Useful for refining the return type of a query, while still delegating /// whether to [get] or [watch] results to the consuming code. /// -/// {@template moor_multi_selectable_example} +/// {@template drift_multi_selectable_example} /// ```dart /// /// Retrieve a page of [Todo]s. /// MultiSelectable pageOfTodos(int page, {int pageSize = 10}) { @@ -101,7 +101,7 @@ abstract class MultiSelectable { /// Useful for refining the return type of a query, while still delegating /// whether to [getSingle] or [watchSingle] results to the consuming code. /// -/// {@template moor_single_selectable_example} +/// {@template drift_single_selectable_example} /// ```dart /// // Retrieve a todo known to exist. /// SingleSelectable entryById(int id) { @@ -120,7 +120,7 @@ abstract class SingleSelectable { /// value. the query returns no or too many rows, the returned future will /// complete with an error. /// - /// {@template moor_single_query_expl} + /// {@template drift_single_query_expl} /// Be aware that this operation won't put a limit clause on this statement, /// if that's needed you would have to do use [SimpleSelectStatement.limit]: /// ```dart @@ -147,7 +147,7 @@ abstract class SingleSelectable { /// `Stream`. If, at any point, the query emits no or more than one rows, /// an error will be added to the stream instead. /// - /// {@macro moor_single_query_expl} + /// {@macro drift_single_query_expl} Stream watchSingle(); } @@ -158,7 +158,7 @@ abstract class SingleSelectable { /// whether to [getSingleOrNull] or [watchSingleOrNull] result to the /// consuming code. /// -/// {@template moor_single_or_null_selectable_example} +/// {@template drift_single_or_null_selectable_example} ///```dart /// // Retrieve a todo from an external link that may not be valid. /// SingleOrNullSelectable entryFromExternalLink(int id) { @@ -177,7 +177,7 @@ abstract class SingleOrNullSelectable { /// value. If the result too many values, this method will throw. If no /// row is returned, `null` will be returned instead. /// - /// {@macro moor_single_query_expl} + /// {@macro drift_single_query_expl} /// /// See also: [Selectable.getSingle], which can be used if the query will /// always evaluate to exactly one row. @@ -191,7 +191,7 @@ abstract class SingleOrNullSelectable { /// If the query emits zero rows at some point, `null` will be added /// to the stream instead. /// - /// {@macro moor_single_query_expl} + /// {@macro drift_single_query_expl} Stream watchSingleOrNull(); } @@ -202,9 +202,9 @@ abstract class SingleOrNullSelectable { /// [Stream], you can refine your return type using one of Selectable's /// base classes: /// -/// {@macro moor_multi_selectable_example} -/// {@macro moor_single_selectable_example} -/// {@macro moor_single_or_null_selectable_example} +/// {@macro drift_multi_selectable_example} +/// {@macro drift_single_selectable_example} +/// {@macro drift_single_or_null_selectable_example} abstract class Selectable implements MultiSelectable, @@ -295,7 +295,7 @@ mixin SingleTableQueryMixin on Query { /// will be the conjunction of both calls. /// /// For more information, see: - /// - The docs on [expressions](https://moor.simonbinder.eu/docs/getting-started/expressions/), + /// - The docs on [expressions](https://drift.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 [DatabaseConnectionUser.select]. diff --git a/drift/lib/src/runtime/query_builder/statements/select/custom_select.dart b/drift/lib/src/runtime/query_builder/statements/select/custom_select.dart index c0d99fa9..14588659 100644 --- a/drift/lib/src/runtime/query_builder/statements/select/custom_select.dart +++ b/drift/lib/src/runtime/query_builder/statements/select/custom_select.dart @@ -1,7 +1,7 @@ part of '../../query_builder.dart'; /// A select statement that is constructed with a raw sql prepared statement -/// instead of the high-level moor api. +/// instead of the high-level drift api. class CustomSelectStatement with Selectable { /// Tables this select statement reads from. When turning this select query /// into an auto-updating stream, that stream will emit new items whenever diff --git a/drift/lib/src/runtime/query_builder/statements/select/select.dart b/drift/lib/src/runtime/query_builder/statements/select/select.dart index 6d48a7cb..8a532868 100644 --- a/drift/lib/src/runtime/query_builder/statements/select/select.dart +++ b/drift/lib/src/runtime/query_builder/statements/select/select.dart @@ -4,7 +4,7 @@ part of '../../query_builder.dart'; /// a table. typedef OrderClauseGenerator = OrderingTerm Function(T tbl); -/// The abstract base class for all select statements in the moor api. +/// The abstract base class for all select statements in the drift api. /// /// Users are not allowed to extend, implement or mix-in this class. @sealed @@ -22,7 +22,7 @@ class SimpleSelectStatement extends Query /// `SELECT DISTINCT` statement in sql). Defaults to false. final bool distinct; - /// Used internally by moor, users will want to call + /// Used internally by drift, users will want to call /// [DatabaseConnectionUser.select] instead. SimpleSelectStatement( DatabaseConnectionUser database, ResultSetImplementation table, @@ -91,7 +91,7 @@ class SimpleSelectStatement extends Query /// ``` /// /// See also: - /// - https://moor.simonbinder.eu/docs/advanced-features/joins/#joins + /// - https://drift.simonbinder.eu/docs/advanced-features/joins/#joins /// - [innerJoin], [leftOuterJoin] and [crossJoin], which can be used to /// construct a [Join]. /// - [DatabaseConnectionUser.alias], which can be used to build statements @@ -112,7 +112,7 @@ class SimpleSelectStatement extends Query return statement; } - /// {@macro moor_select_addColumns} + /// {@macro drift_select_addColumns} JoinedSelectStatement addColumns(List expressions) { return join([])..addColumns(expressions); } @@ -163,7 +163,7 @@ class TypedResult { throw ArgumentError( 'Invalid table passed to readTable: ${table.aliasedName}. This row ' 'does not contain values for that table. \n' - 'In moor version 4, you have to use readTableNull for outer joins.'); + 'Please use readTableOrNull for outer joins.'); } return _parsedData[table] as D; diff --git a/drift/lib/src/runtime/query_builder/statements/select/select_with_join.dart b/drift/lib/src/runtime/query_builder/statements/select/select_with_join.dart index dfb9c48d..8ebcd462 100644 --- a/drift/lib/src/runtime/query_builder/statements/select/select_with_join.dart +++ b/drift/lib/src/runtime/query_builder/statements/select/select_with_join.dart @@ -8,7 +8,7 @@ class JoinedSelectStatement extends Query with LimitContainerMixin, Selectable implements BaseSelectStatement { - /// Used internally by moor, users should use [SimpleSelectStatement.join] + /// Used internally by drift, users should use [SimpleSelectStatement.join] /// instead. JoinedSelectStatement(DatabaseConnectionUser database, ResultSetImplementation table, this._joins, @@ -141,7 +141,7 @@ class JoinedSelectStatement orderByExpr = OrderBy(terms); } - /// {@template moor_select_addColumns} + /// {@template drift_select_addColumns} /// Adds a custom expression to the query. /// /// The database will evaluate the [Expression] for each row found for this @@ -158,7 +158,7 @@ class JoinedSelectStatement /// ``` /// /// See also: - /// - The docs on expressions: https://moor.simonbinder.eu/docs/getting-started/expressions/ + /// - The docs on expressions: https://drift.simonbinder.eu/docs/getting-started/expressions/ /// {@endtemplate} void addColumns(Iterable expressions) { _selectedColumns.addAll(expressions); @@ -169,7 +169,7 @@ class JoinedSelectStatement /// Always returns the same instance. /// /// See also: - /// - https://moor.simonbinder.eu/docs/advanced-features/joins/#joins + /// - https://drift.simonbinder.eu/docs/advanced-features/joins/#joins /// - [SimpleSelectStatement.join], which is used for the first join /// - [innerJoin], [leftOuterJoin] and [crossJoin], which can be used to /// construct a [Join]. @@ -259,7 +259,7 @@ class JoinedSelectStatement message: 'This query contained the table ${table.entityName} more than ' 'once. Is this a typo? \n' 'If you need a join that includes the same table more than once, you ' - 'need to alias() at least one table. See https://moor.simonbinder.eu/queries/joins#aliases ' + 'need to alias() at least one table. See https://drift.simonbinder.eu/queries/joins#aliases ' 'for an example.', cause: cause, trace: trace, diff --git a/drift/lib/src/runtime/query_builder/statements/update.dart b/drift/lib/src/runtime/query_builder/statements/update.dart index 4bc9f6d3..84ea230c 100644 --- a/drift/lib/src/runtime/query_builder/statements/update.dart +++ b/drift/lib/src/runtime/query_builder/statements/update.dart @@ -3,7 +3,7 @@ part of '../query_builder.dart'; /// Represents an `UPDATE` statement in sql. class UpdateStatement extends Query with SingleTableQueryMixin { - /// Used internally by moor, construct an update statement + /// Used internally by drift, construct an update statement UpdateStatement(DatabaseConnectionUser database, TableInfo table) : super(database, table); @@ -55,7 +55,7 @@ class UpdateStatement extends Query /// /// When [dontExecute] is true (defaults to false), the query will __NOT__ be /// run, but all the validations are still in place. This is mainly used - /// internally by moor. + /// internally by drift. /// /// Returns the amount of rows that have been affected by this operation. /// @@ -89,7 +89,7 @@ class UpdateStatement extends Query /// /// When [dontExecute] is true (defaults to false), the query will __NOT__ be /// run, but all the validations are still in place. This is mainly used - /// internally by moor. + /// internally by drift. /// /// Returns true if a row was affected by this operation. /// diff --git a/drift/lib/src/runtime/types/custom_type.dart b/drift/lib/src/runtime/types/custom_type.dart index cd2f34e9..437f5492 100644 --- a/drift/lib/src/runtime/types/custom_type.dart +++ b/drift/lib/src/runtime/types/custom_type.dart @@ -3,7 +3,7 @@ part of 'sql_types.dart'; /// Maps a custom dart object of type [D] into a primitive type [S] understood /// by the sqlite backend. /// -/// Moor currently supports [DateTime], [double], [int], [Uint8List], [bool] +/// Dart currently supports [DateTime], [double], [int], [Uint8List], [bool] /// and [String] for [S]. /// /// Also see [BuildColumn.map] for details. diff --git a/drift/lib/src/runtime/types/type_system.dart b/drift/lib/src/runtime/types/type_system.dart index 8953a915..83e5790f 100644 --- a/drift/lib/src/runtime/types/type_system.dart +++ b/drift/lib/src/runtime/types/type_system.dart @@ -52,7 +52,7 @@ class SqlTypeSystem { static String mapToSqlConstant(Object? dart) { if (dart == null) return 'NULL'; - // todo: Inline and remove types in the next major moor version + // todo: Inline and remove types in the next major drift version if (dart is bool) { return const BoolType().mapToSqlConstant(dart); } else if (dart is String) { diff --git a/drift/lib/src/web/sql_js.dart b/drift/lib/src/web/sql_js.dart index 36773e25..506a071d 100644 --- a/drift/lib/src/web/sql_js.dart +++ b/drift/lib/src/web/sql_js.dart @@ -4,8 +4,8 @@ import 'dart:js'; import 'dart:typed_data'; // We write our own mapping code to js instead of depending on package:js -// This way, projects using moor can run on flutter as long as they don't import -// this file. +// This way, projects using drift can run on flutter as long as they don't +// import this file. Completer? _moduleCompleter; @@ -17,10 +17,10 @@ Future initSqlJs() { _moduleCompleter = Completer(); if (!context.hasProperty('initSqlJs')) { - return Future.error( - UnsupportedError('Could not access the sql.js javascript library. ' - 'The moor documentation contains instructions on how to setup moor ' - 'the web, which might help you fix this.')); + return Future.error(UnsupportedError( + 'Could not access the sql.js javascript library. ' + 'The drift documentation contains instructions on how to setup drift ' + 'the web, which might help you fix this.')); } (context.callMethod('initSqlJs') as JsObject) diff --git a/drift/lib/src/web/storage.dart b/drift/lib/src/web/storage.dart index 7425aa87..f9eaf111 100644 --- a/drift/lib/src/web/storage.dart +++ b/drift/lib/src/web/storage.dart @@ -1,6 +1,6 @@ part of 'package:drift/web.dart'; -/// Interface to control how moor should store data on the web. +/// Interface to control how drift should store data on the web. abstract class DriftWebStorage { /// Opens the storage implementation. Future open(); @@ -74,7 +74,7 @@ abstract class DriftWebStorage { // Try opening a mock database to check if IndexedDB is really // available. This avoids the problem with Firefox incorrectly // reporting IndexedDB as supported in private mode. - final mockDb = await window.indexedDB!.open('moor_mock_db'); + final mockDb = await window.indexedDB!.open('drift_mock_db'); mockDb.close(); } } catch (error) { diff --git a/drift/lib/src/web/web_db.dart b/drift/lib/src/web/web_db.dart index edaa44ee..c83bdc62 100644 --- a/drift/lib/src/web/web_db.dart +++ b/drift/lib/src/web/web_db.dart @@ -5,7 +5,7 @@ part of 'package:drift/web.dart'; /// The bytes returned should represent a valid sqlite3 database file. typedef CreateWebDatabase = Future Function(); -/// Experimental moor backend for the web. To use this platform, you need to +/// Experimental drift backend for the web. To use this platform, you need to /// include the latest version of `sql.js` in your html. class WebDatabase extends DelegatedDatabase { /// A database executor that works on the web. @@ -183,7 +183,7 @@ class _WebVersionDelegate extends DynamicVersionDelegate { _WebVersionDelegate(this.delegate); - // Note: Earlier moor versions used to store the database version in a special + // Note: Earlier versions used to store the database version in a special // field in local storage (moor_db_version_). Since 2.3, we instead use // the user_version pragma, but still need to keep backwards compatibility. diff --git a/drift/lib/web.dart b/drift/lib/web.dart index d886412e..10f3ee8e 100644 --- a/drift/lib/web.dart +++ b/drift/lib/web.dart @@ -1,9 +1,9 @@ -/// A version of moor that runs on the web by using [sql.js](https://github.com/sql-js/sql.js) +/// A version of drift that runs on the web by using [sql.js](https://github.com/sql-js/sql.js) /// You manually need to include that library into your website to use the -/// web version of moor. See [the documentation](https://moor.simonbinder.eu/web) +/// web version of drift. See [the documentation](https://drift.simonbinder.eu/web) /// for a more detailed instruction. @experimental -library moor_web; +library drift.web; import 'dart:async'; import 'dart:html'; diff --git a/drift/test/data/tables/custom_tables.dart b/drift/test/data/tables/custom_tables.dart index fd885b93..6529fd42 100644 --- a/drift/test/data/tables/custom_tables.dart +++ b/drift/test/data/tables/custom_tables.dart @@ -8,7 +8,7 @@ export 'data_classes.dart'; part 'custom_tables.g.dart'; @DriftDatabase( - include: {'tables.moor'}, + include: {'tables.drift'}, queries: { 'writeConfig': 'REPLACE INTO config (config_key, config_value) ' 'VALUES (:key, :value)' diff --git a/drift/test/data/tables/tables.moor b/drift/test/data/tables/tables.drift similarity index 100% rename from drift/test/data/tables/tables.moor rename to drift/test/data/tables/tables.drift diff --git a/drift/test/engines/connection_pool_integration_test.dart b/drift/test/engines/connection_pool_integration_test.dart index 47d30b81..f06af80d 100644 --- a/drift/test/engines/connection_pool_integration_test.dart +++ b/drift/test/engines/connection_pool_integration_test.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; import '../data/tables/todos.dart'; -String fileName = 'moor-wal-integration-test.db'; +String fileName = 'drift-wal-integration-test.db'; final _file = File(join(Directory.systemTemp.path, fileName)); QueryExecutor _createExecutor() => NativeDatabase(_file); diff --git a/drift/test/expressions/null_check_test.dart b/drift/test/expressions/null_check_test.dart index 6dbdee56..740929ea 100644 --- a/drift/test/expressions/null_check_test.dart +++ b/drift/test/expressions/null_check_test.dart @@ -1,5 +1,5 @@ import 'package:drift/drift.dart'; -import 'package:drift/drift.dart' as moor; +import 'package:drift/drift.dart' as drift; import 'package:test/test.dart'; import '../data/utils/expect_equality.dart'; @@ -10,7 +10,7 @@ void main() { CustomExpression('name', precedence: Precedence.primary); test('IS NULL expressions are generated', () { - final oldFunction = moor.isNull(innerExpression); + final oldFunction = drift.isNull(innerExpression); final extension = innerExpression.isNull(); expect(oldFunction, generates('name IS NULL')); @@ -20,7 +20,7 @@ void main() { }); test('IS NOT NULL expressions are generated', () { - final oldFunction = moor.isNotNull(innerExpression); + final oldFunction = drift.isNotNull(innerExpression); final extension = innerExpression.isNotNull(); expect(oldFunction, generates('name IS NOT NULL')); @@ -30,7 +30,8 @@ void main() { }); test('generates COALESCE expressions', () { - final expr = moor.coalesce([const Constant(null), const Constant(3)]); + final expr = + drift.coalesce([const Constant(null), const Constant(3)]); expect(expr, generates('COALESCE(NULL, 3)')); }); diff --git a/drift/test/ffi/close_existing_test.dart b/drift/test/ffi/close_existing_test.dart index 1b10b817..60f374a5 100644 --- a/drift/test/ffi/close_existing_test.dart +++ b/drift/test/ffi/close_existing_test.dart @@ -8,7 +8,7 @@ import 'package:test/test.dart'; void main() { test('can close lost instances', () async { - final file = File(p.join(Directory.systemTemp.path, 'moor_close.db')); + final file = File(p.join(Directory.systemTemp.path, 'drift_close.db')); if (file.existsSync()) file.deleteSync(); // Create the first database holding the lock diff --git a/drift/test/ffi/moor_functions_test.dart b/drift/test/ffi/moor_functions_test.dart index 7f6de651..4800127b 100644 --- a/drift/test/ffi/moor_functions_test.dart +++ b/drift/test/ffi/moor_functions_test.dart @@ -1,14 +1,14 @@ @TestOn('vm') import 'dart:math'; -import 'package:drift/src/ffi/moor_ffi_functions.dart'; +import 'package:drift/src/ffi/native_functions.dart'; import 'package:sqlite3/sqlite3.dart'; import 'package:test/test.dart'; void main() { late Database db; - setUp(() => db = sqlite3.openInMemory()..useMoorVersions()); + setUp(() => db = sqlite3.openInMemory()..useNativeFunctions()); tearDown(() => db.dispose()); dynamic selectSingle(String expression) { diff --git a/drift/test/integration_tests/moor_files_test.dart b/drift/test/integration_tests/moor_files_test.dart index 7f20c206..acd6b006 100644 --- a/drift/test/integration_tests/moor_files_test.dart +++ b/drift/test/integration_tests/moor_files_test.dart @@ -51,7 +51,7 @@ const _defaultInsert = 'INSERT INTO config (config_key, config_value) ' "VALUES ('key', 'values')"; void main() { - // see ../data/tables/tables.moor + // see ../data/tables/tables.drift late MockExecutor mock; late CustomTablesDb db; @@ -62,7 +62,7 @@ void main() { tearDown(() => db.close()); - test('creates everything as specified in .moor files', () async { + test('creates everything as specified in .drift files', () async { await db.createMigrator().createAll(); verify(mock.runCustom(_createNoIds, [])); diff --git a/drift/test/isolate_test.dart b/drift/test/isolate_test.dart index cc1eb341..400d280c 100644 --- a/drift/test/isolate_test.dart +++ b/drift/test/isolate_test.dart @@ -10,9 +10,9 @@ import 'package:test/test.dart'; import 'data/tables/todos.dart'; void main() { - // Using the MoorIsolate apis without actually running on a background isolate - // is pointless, but we can't collect coverage for background isolates: - // https://github.com/dart-lang/test/issues/1108 + // Using the DriftIsolate apis without actually running on a background + // isolate is pointless, but we can't collect coverage for background + // isolates: https://github.com/dart-lang/test/issues/1108 group('in same isolate', () { DriftIsolate spawnInSame() { return DriftIsolate.inCurrent(_backgroundConnection); @@ -33,14 +33,14 @@ void main() { // three isolates: // 1. this one, starting a query stream // 2. another one running an insert - // 3. the MoorIsolate executor the other two are connecting to - final moorIsolate = await DriftIsolate.spawn(_backgroundConnection); + // 3. the DriftIsolate executor the other two are connecting to + final driftIsolate = await DriftIsolate.spawn(_backgroundConnection); final receiveDone = ReceivePort(); final writer = await Isolate.spawn(_writeTodoEntryInBackground, - _BackgroundEntryMessage(moorIsolate, receiveDone.sendPort)); + _BackgroundEntryMessage(driftIsolate, receiveDone.sendPort)); - final db = TodoDb.connect(await moorIsolate.connect()); + final db = TodoDb.connect(await driftIsolate.connect()); final expectedEntry = const TypeMatcher() .having((e) => e.content, 'content', 'Hello from background'); @@ -57,7 +57,7 @@ void main() { await receiveDone.first; writer.kill(); await expectation; - await moorIsolate.shutdownAll(); + await driftIsolate.shutdownAll(); }, tags: 'background_isolate'); test('errors propagate across isolates', () async { @@ -88,8 +88,8 @@ void main() { // The isolate shold eventually exit! expect(done.first, completion(anything)); - final moor = await spawned.first as DriftIsolate; - await moor.shutdownAll(); + final drift = await spawned.first as DriftIsolate; + await drift.shutdownAll(); }, tags: 'background_isolate'); } @@ -282,8 +282,8 @@ class _BackgroundEntryMessage { } void _createBackground(SendPort send) { - final moor = DriftIsolate.inCurrent( + final drift = DriftIsolate.inCurrent( () => DatabaseConnection.fromExecutor(NativeDatabase.memory()), killIsolateWhenDone: true); - send.send(moor); + send.send(drift); } diff --git a/drift/test/streams_test.dart b/drift/test/streams_test.dart index 38da564f..27a9d359 100644 --- a/drift/test/streams_test.dart +++ b/drift/test/streams_test.dart @@ -330,7 +330,7 @@ void main() { expect(db.customSelect('SELECT 1').watchSingle().isBroadcast, isTrue); }); - test('moor streams can be used with switchMap in rxdart', () async { + test('drift streams can be used with switchMap in rxdart', () async { // Regression test for https://github.com/simolus3/moor/issues/500 when(executor.runSelect(any, any)).thenAnswer((i) async { final sql = i.positionalArguments.first as String; diff --git a/drift/test/types/datetime_test.dart b/drift/test/types/datetime_test.dart index 762517f8..e7bc2f78 100644 --- a/drift/test/types/datetime_test.dart +++ b/drift/test/types/datetime_test.dart @@ -1,4 +1,4 @@ -import 'package:drift/drift.dart' as moor; +import 'package:drift/drift.dart' as drift; import 'package:test/test.dart'; const _exampleUnixSqlite = 1550172560; @@ -7,7 +7,7 @@ final _exampleDateTime = DateTime.fromMillisecondsSinceEpoch(_exampleUnixMillis); void main() { - const type = moor.DateTimeType(); + const type = drift.DateTimeType(); group('DateTimes', () { test('can be read from unix stamps returned by sql', () { diff --git a/drift/test/types/real_type_test.dart b/drift/test/types/real_type_test.dart index 49dd90b9..73122990 100644 --- a/drift/test/types/real_type_test.dart +++ b/drift/test/types/real_type_test.dart @@ -1,8 +1,8 @@ -import 'package:drift/drift.dart' as moor; +import 'package:drift/drift.dart' as drift; import 'package:test/test.dart'; void main() { - const type = moor.RealType(); + const type = drift.RealType(); group('RealType', () { test('can be read from floating point values returned by sql', () {