From 44802b1d8e909c7ca3b2ae657cd9fcd1998400d7 Mon Sep 17 00:00:00 2001 From: hendrikvanderkaaden Date: Mon, 29 Apr 2024 09:41:27 +0200 Subject: [PATCH] Delete .g files and update gitignore --- .gitignore | 2 +- .../autoincrement/autoinc_test.g.dart | 151 ----- .../test/integration/blob/blob_test.g.dart | 147 ----- .../boolean_conversions/bool_test.g.dart | 175 ------ floor_common/test/integration/database.g.dart | 447 --------------- .../test/integration/fts/mail_database.g.dart | 212 ------- .../inheritance/dao_inheritance_test.g.dart | 144 ----- .../entity_inheritance_test.g.dart | 170 ------ .../type_converter/order_database.g.dart | 166 ------ .../test/integration/view/view_test.g.dart | 521 ------------------ 10 files changed, 1 insertion(+), 2134 deletions(-) delete mode 100644 floor_common/test/integration/autoincrement/autoinc_test.g.dart delete mode 100644 floor_common/test/integration/blob/blob_test.g.dart delete mode 100644 floor_common/test/integration/boolean_conversions/bool_test.g.dart delete mode 100644 floor_common/test/integration/database.g.dart delete mode 100644 floor_common/test/integration/fts/mail_database.g.dart delete mode 100644 floor_common/test/integration/inheritance/dao_inheritance_test.g.dart delete mode 100644 floor_common/test/integration/inheritance/entity_inheritance_test.g.dart delete mode 100644 floor_common/test/integration/type_converter/order_database.g.dart delete mode 100644 floor_common/test/integration/view/view_test.g.dart diff --git a/.gitignore b/.gitignore index 3406c8e2..10d6e236 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Miscellaneous -floor/**/*.g.dart +floor_common/**/*.g.dart *.class *.log *.pyc diff --git a/floor_common/test/integration/autoincrement/autoinc_test.g.dart b/floor_common/test/integration/autoincrement/autoinc_test.g.dart deleted file mode 100644 index 875cfb82..00000000 --- a/floor_common/test/integration/autoincrement/autoinc_test.g.dart +++ /dev/null @@ -1,151 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'autoinc_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - AIDao? _aiDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `AutoIncEntity` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `decimal` REAL NOT NULL)'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - AIDao get aiDao { - return _aiDaoInstance ??= _$AIDao(database, changeListener); - } -} - -class _$AIDao extends AIDao { - _$AIDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _autoIncEntityInsertionAdapter = InsertionAdapter( - database, - 'AutoIncEntity', - (AutoIncEntity item) => - {'id': item.id, 'decimal': item.decimal}); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _autoIncEntityInsertionAdapter; - - @override - Future findWithId(int val) async { - return _queryAdapter.query('SELECT * FROM AutoIncEntity where id = ?1', - mapper: (Map row) => - AutoIncEntity(row['decimal'] as double, id: row['id'] as int?), - arguments: [val]); - } - - @override - Future> findAll() async { - return _queryAdapter.queryList('SELECT * FROM AutoIncEntity', - mapper: (Map row) => - AutoIncEntity(row['decimal'] as double, id: row['id'] as int?)); - } - - @override - Future insertAIEntity(AutoIncEntity e) async { - await _autoIncEntityInsertionAdapter.insert(e, OnConflictStrategy.abort); - } -} diff --git a/floor_common/test/integration/blob/blob_test.g.dart b/floor_common/test/integration/blob/blob_test.g.dart deleted file mode 100644 index 54932cb0..00000000 --- a/floor_common/test/integration/blob/blob_test.g.dart +++ /dev/null @@ -1,147 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'blob_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - PersonDao? _personDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `Person` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `picture` BLOB NOT NULL, PRIMARY KEY (`id`))'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - PersonDao get personDao { - return _personDaoInstance ??= _$PersonDao(database, changeListener); - } -} - -class _$PersonDao extends PersonDao { - _$PersonDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _personInsertionAdapter = InsertionAdapter( - database, - 'Person', - (Person item) => { - 'id': item.id, - 'name': item.name, - 'picture': item.picture - }); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _personInsertionAdapter; - - @override - Future findPersonByPicture(Uint8List picture) async { - return _queryAdapter.query('SELECT * FROM Person WHERE picture = ?1', - mapper: (Map row) => Person(row['id'] as int, - row['name'] as String, row['picture'] as Uint8List), - arguments: [picture]); - } - - @override - Future insertPerson(Person person) async { - await _personInsertionAdapter.insert(person, OnConflictStrategy.abort); - } -} diff --git a/floor_common/test/integration/boolean_conversions/bool_test.g.dart b/floor_common/test/integration/boolean_conversions/bool_test.g.dart deleted file mode 100644 index d517c02f..00000000 --- a/floor_common/test/integration/boolean_conversions/bool_test.g.dart +++ /dev/null @@ -1,175 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'bool_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - BoolDao? _boolDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `BooleanClass` (`id` INTEGER, `nullable` INTEGER, `nonNullable` INTEGER NOT NULL, PRIMARY KEY (`id`))'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - BoolDao get boolDao { - return _boolDaoInstance ??= _$BoolDao(database, changeListener); - } -} - -class _$BoolDao extends BoolDao { - _$BoolDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _booleanClassInsertionAdapter = InsertionAdapter( - database, - 'BooleanClass', - (BooleanClass item) => { - 'id': item.id == null ? null : (item.id! ? 1 : 0), - 'nullable': - item.nullable == null ? null : (item.nullable! ? 1 : 0), - 'nonNullable': item.nonNullable ? 1 : 0 - }); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _booleanClassInsertionAdapter; - - @override - Future findWithNonNullable(bool val) async { - return _queryAdapter.query( - 'SELECT * FROM BooleanClass where nonNullable = ?1', - mapper: (Map row) => BooleanClass( - row['id'] == null ? null : (row['id'] as int) != 0, - nullable: - row['nullable'] == null ? null : (row['nullable'] as int) != 0, - nonNullable: (row['nonNullable'] as int) != 0), - arguments: [val ? 1 : 0]); - } - - @override - Future findWithNullable(bool val) async { - return _queryAdapter.query('SELECT * FROM BooleanClass where nullable = ?1', - mapper: (Map row) => BooleanClass( - row['id'] == null ? null : (row['id'] as int) != 0, - nullable: - row['nullable'] == null ? null : (row['nullable'] as int) != 0, - nonNullable: (row['nonNullable'] as int) != 0), - arguments: [val ? 1 : 0]); - } - - @override - Future findWithNullableBeingNull() async { - return _queryAdapter.query( - 'SELECT * FROM BooleanClass where nullable IS NULL', - mapper: (Map row) => BooleanClass( - row['id'] == null ? null : (row['id'] as int) != 0, - nullable: - row['nullable'] == null ? null : (row['nullable'] as int) != 0, - nonNullable: (row['nonNullable'] as int) != 0)); - } - - @override - Future insertBoolC(BooleanClass person) async { - await _booleanClassInsertionAdapter.insert( - person, OnConflictStrategy.abort); - } -} diff --git a/floor_common/test/integration/database.g.dart b/floor_common/test/integration/database.g.dart deleted file mode 100644 index 35f5f67f..00000000 --- a/floor_common/test/integration/database.g.dart +++ /dev/null @@ -1,447 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'database.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - PersonDao? _personDaoInstance; - - DogDao? _dogDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 2, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `person` (`id` INTEGER, `custom_name` TEXT NOT NULL, PRIMARY KEY (`id`))'); - await database.execute( - 'CREATE TABLE IF NOT EXISTS `dog` (`id` INTEGER, `name` TEXT NOT NULL, `nick_name` TEXT NOT NULL, `owner_id` INTEGER NOT NULL, FOREIGN KEY (`owner_id`) REFERENCES `person` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, PRIMARY KEY (`id`))'); - await database.execute( - 'CREATE INDEX `index_person_custom_name` ON `person` (`custom_name`)'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - PersonDao get personDao { - return _personDaoInstance ??= _$PersonDao(database, changeListener); - } - - @override - DogDao get dogDao { - return _dogDaoInstance ??= _$DogDao(database, changeListener); - } -} - -class _$PersonDao extends PersonDao { - _$PersonDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database, changeListener), - _personInsertionAdapter = InsertionAdapter( - database, - 'person', - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener), - _personUpdateAdapter = UpdateAdapter( - database, - 'person', - ['id'], - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener), - _personDeletionAdapter = DeletionAdapter( - database, - 'person', - ['id'], - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _personInsertionAdapter; - - final UpdateAdapter _personUpdateAdapter; - - final DeletionAdapter _personDeletionAdapter; - - @override - Future> findAllPersons() async { - return _queryAdapter.queryList('SELECT * FROM person', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String)); - } - - @override - Stream> findAllPersonsAsStream() { - return _queryAdapter.queryListStream('SELECT * FROM person', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - queryableName: 'person', - isView: false); - } - - @override - Future findPersonById(int id) async { - return _queryAdapter.query('SELECT * FROM person WHERE id = ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id]); - } - - @override - Stream findPersonByIdAsStream(int id) { - return _queryAdapter.queryStream('SELECT * FROM person WHERE id = ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id], - queryableName: 'person', - isView: false); - } - - @override - Stream uniqueRecordsCountAsStream() { - return _queryAdapter.queryStream('SELECT DISTINCT COUNT(id) FROM person', - mapper: (Map row) => row.values.first as int, - queryableName: 'person', - isView: false); - } - - @override - Future findPersonByIdAndName( - int id, - String name, - ) async { - return _queryAdapter.query( - 'SELECT * FROM person WHERE id = ?1 AND custom_name = ?2', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id, name]); - } - - @override - Future> findPersonsWithIds(List ids) async { - const offset = 1; - final _sqliteVariablesForIds = - Iterable.generate(ids.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE id IN (' + _sqliteVariablesForIds + ')', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [...ids]); - } - - @override - Future> findPersonsWithNames(List names) async { - const offset = 1; - final _sqliteVariablesForNames = - Iterable.generate(names.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name IN (' + - _sqliteVariablesForNames + - ')', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [...names]); - } - - @override - Future> findPersonsWithNamesComplex( - int reference, - List names, - List moreNames, - ) async { - int offset = 2; - final _sqliteVariablesForNames = - Iterable.generate(names.length, (i) => '?${i + offset}') - .join(','); - offset += names.length; - final _sqliteVariablesForMoreNames = - Iterable.generate(moreNames.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name IN (' + - _sqliteVariablesForNames + - ') AND id>=?1 OR custom_name IN (' + - _sqliteVariablesForMoreNames + - ') AND id<=?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [reference, ...names, ...moreNames]); - } - - @override - Future> findPersonsWithNamesLike(String name) async { - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name LIKE ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [name]); - } - - @override - Future> findPersonsWithEmptyName() async { - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name == \'\'', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String)); - } - - @override - Future deleteAllPersons() async { - await _queryAdapter.queryNoReturn('DELETE FROM person'); - } - - @override - Stream> findAllDogsOfPersonAsStream(int id) { - return _queryAdapter.queryListStream( - 'SELECT * FROM dog WHERE owner_id = ?1', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int), - arguments: [id], - queryableName: 'dog', - isView: false); - } - - @override - Future insertPerson(Person person) async { - await _personInsertionAdapter.insert(person, OnConflictStrategy.replace); - } - - @override - Future insertPersons(List persons) async { - await _personInsertionAdapter.insertList(persons, OnConflictStrategy.abort); - } - - @override - Future insertPersonWithReturn(Person person) { - return _personInsertionAdapter.insertAndReturnId( - person, OnConflictStrategy.abort); - } - - @override - Future> insertPersonsWithReturn(List persons) { - return _personInsertionAdapter.insertListAndReturnIds( - persons, OnConflictStrategy.abort); - } - - @override - Future updatePerson(Person person) async { - await _personUpdateAdapter.update(person, OnConflictStrategy.abort); - } - - @override - Future updatePersons(List persons) async { - await _personUpdateAdapter.updateList(persons, OnConflictStrategy.abort); - } - - @override - Future updatePersonWithReturn(Person person) { - return _personUpdateAdapter.updateAndReturnChangedRows( - person, OnConflictStrategy.abort); - } - - @override - Future updatePersonsWithReturn(List persons) { - return _personUpdateAdapter.updateListAndReturnChangedRows( - persons, OnConflictStrategy.abort); - } - - @override - Future deletePerson(Person person) async { - await _personDeletionAdapter.delete(person); - } - - @override - Future deletePersons(List person) async { - await _personDeletionAdapter.deleteList(person); - } - - @override - Future deletePersonWithReturn(Person person) { - return _personDeletionAdapter.deleteAndReturnChangedRows(person); - } - - @override - Future deletePersonsWithReturn(List persons) { - return _personDeletionAdapter.deleteListAndReturnChangedRows(persons); - } - - @override - Future replacePersons(List persons) async { - if (database is sqflite.Transaction) { - await super.replacePersons(persons); - } else { - await (database as sqflite.Database) - .transaction((transaction) async { - final transactionDatabase = _$TestDatabase(changeListener) - ..database = transaction; - await transactionDatabase.personDao.replacePersons(persons); - }); - } - } - - @override - Future> replacePersonsAndReturn(List persons) async { - if (database is sqflite.Transaction) { - return super.replacePersonsAndReturn(persons); - } else { - return (database as sqflite.Database) - .transaction>((transaction) async { - final transactionDatabase = _$TestDatabase(changeListener) - ..database = transaction; - return transactionDatabase.personDao.replacePersonsAndReturn(persons); - }); - } - } -} - -class _$DogDao extends DogDao { - _$DogDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _dogInsertionAdapter = InsertionAdapter( - database, - 'dog', - (Dog item) => { - 'id': item.id, - 'name': item.name, - 'nick_name': item.nickName, - 'owner_id': item.ownerId - }, - changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _dogInsertionAdapter; - - @override - Future findDogForPersonId(int id) async { - return _queryAdapter.query('SELECT * FROM dog WHERE owner_id = ?1', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int), - arguments: [id]); - } - - @override - Future> findAllDogs() async { - return _queryAdapter.queryList('SELECT * FROM dog', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int)); - } - - @override - Future insertDog(Dog dog) async { - await _dogInsertionAdapter.insert(dog, OnConflictStrategy.abort); - } -} diff --git a/floor_common/test/integration/fts/mail_database.g.dart b/floor_common/test/integration/fts/mail_database.g.dart deleted file mode 100644 index bc803044..00000000 --- a/floor_common/test/integration/fts/mail_database.g.dart +++ /dev/null @@ -1,212 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'mail_database.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $MailDatabaseBuilderContract { - /// Adds migrations to the builder. - $MailDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $MailDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorMailDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $MailDatabaseBuilderContract databaseBuilder(String name) => - _$MailDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $MailDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$MailDatabaseBuilder(null); -} - -class _$MailDatabaseBuilder implements $MailDatabaseBuilderContract { - _$MailDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $MailDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $MailDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$MailDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$MailDatabase extends MailDatabase { - _$MailDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - MailDao? _mailDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE VIRTUAL TABLE IF NOT EXISTS `mail` USING fts4(`rowid` INTEGER NOT NULL, `text` TEXT NOT NULL, PRIMARY KEY (`rowid`), tokenize=unicode61 )'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - MailDao get mailDao { - return _mailDaoInstance ??= _$MailDao(database, changeListener); - } -} - -class _$MailDao extends MailDao { - _$MailDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database, changeListener), - _mailInsertionAdapter = InsertionAdapter( - database, - 'mail', - (Mail item) => - {'rowid': item.id, 'text': item.text}, - changeListener), - _mailUpdateAdapter = UpdateAdapter( - database, - 'mail', - ['rowid'], - (Mail item) => - {'rowid': item.id, 'text': item.text}, - changeListener), - _mailDeletionAdapter = DeletionAdapter( - database, - 'mail', - ['rowid'], - (Mail item) => - {'rowid': item.id, 'text': item.text}, - changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _mailInsertionAdapter; - - final UpdateAdapter _mailUpdateAdapter; - - final DeletionAdapter _mailDeletionAdapter; - - @override - Future findMailById(int id) async { - return _queryAdapter.query('SELECT * FROM mail WHERE rowid = ?1', - mapper: (Map row) => - Mail(row['rowid'] as int, row['text'] as String), - arguments: [id]); - } - - @override - Future> findMailByKey(String key) async { - return _queryAdapter.queryList('SELECT * FROM mail WHERE text match ?1', - mapper: (Map row) => - Mail(row['rowid'] as int, row['text'] as String), - arguments: [key]); - } - - @override - Future> findAllMails() async { - return _queryAdapter.queryList('SELECT * FROM mail', - mapper: (Map row) => - Mail(row['rowid'] as int, row['text'] as String)); - } - - @override - Stream> findAllMailsAsStream() { - return _queryAdapter.queryListStream('SELECT * FROM mail', - mapper: (Map row) => - Mail(row['rowid'] as int, row['text'] as String), - queryableName: 'mail', - isView: false); - } - - @override - Future insertMail(Mail mailInfo) async { - await _mailInsertionAdapter.insert(mailInfo, OnConflictStrategy.abort); - } - - @override - Future insertMails(List mailInfo) async { - await _mailInsertionAdapter.insertList(mailInfo, OnConflictStrategy.abort); - } - - @override - Future updateMail(Mail mailInfo) async { - await _mailUpdateAdapter.update(mailInfo, OnConflictStrategy.abort); - } - - @override - Future updateMails(List mailInfo) async { - await _mailUpdateAdapter.updateList(mailInfo, OnConflictStrategy.abort); - } - - @override - Future deleteMail(Mail mailInfo) async { - await _mailDeletionAdapter.delete(mailInfo); - } - - @override - Future deleteMails(List mailInfo) async { - await _mailDeletionAdapter.deleteList(mailInfo); - } -} diff --git a/floor_common/test/integration/inheritance/dao_inheritance_test.g.dart b/floor_common/test/integration/inheritance/dao_inheritance_test.g.dart deleted file mode 100644 index 58c86590..00000000 --- a/floor_common/test/integration/inheritance/dao_inheritance_test.g.dart +++ /dev/null @@ -1,144 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'dao_inheritance_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - PersonDao? _personDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `Person` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, PRIMARY KEY (`id`))'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - PersonDao get personDao { - return _personDaoInstance ??= _$PersonDao(database, changeListener); - } -} - -class _$PersonDao extends PersonDao { - _$PersonDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _personInsertionAdapter = InsertionAdapter( - database, - 'Person', - (Person item) => - {'id': item.id, 'name': item.name}); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _personInsertionAdapter; - - @override - Future findPersonById(int id) async { - return _queryAdapter.query('SELECT * FROM Person WHERE id = ?1', - mapper: (Map row) => - Person(row['id'] as int, row['name'] as String), - arguments: [id]); - } - - @override - Future insertItem(Person item) async { - await _personInsertionAdapter.insert(item, OnConflictStrategy.abort); - } -} diff --git a/floor_common/test/integration/inheritance/entity_inheritance_test.g.dart b/floor_common/test/integration/inheritance/entity_inheritance_test.g.dart deleted file mode 100644 index 2de28d1f..00000000 --- a/floor_common/test/integration/inheritance/entity_inheritance_test.g.dart +++ /dev/null @@ -1,170 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'entity_inheritance_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $TestDatabaseBuilderContract { - /// Adds migrations to the builder. - $TestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $TestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract databaseBuilder(String name) => - _$TestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $TestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$TestDatabaseBuilder(null); -} - -class _$TestDatabaseBuilder implements $TestDatabaseBuilderContract { - _$TestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $TestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $TestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$TestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$TestDatabase extends TestDatabase { - _$TestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - CommentDao? _commentDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `comments` (`author` TEXT NOT NULL, `content` TEXT NOT NULL, `id` INTEGER NOT NULL, `create_time` TEXT NOT NULL, `update_time` TEXT, PRIMARY KEY (`id`))'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - CommentDao get commentDao { - return _commentDaoInstance ??= _$CommentDao(database, changeListener); - } -} - -class _$CommentDao extends CommentDao { - _$CommentDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _commentInsertionAdapter = InsertionAdapter( - database, - 'comments', - (Comment item) => { - 'author': item.author, - 'content': item.content, - 'id': item.id, - 'create_time': item.createTime, - 'update_time': item.updateTime - }), - _commentDeletionAdapter = DeletionAdapter( - database, - 'comments', - ['id'], - (Comment item) => { - 'author': item.author, - 'content': item.content, - 'id': item.id, - 'create_time': item.createTime, - 'update_time': item.updateTime - }); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _commentInsertionAdapter; - - final DeletionAdapter _commentDeletionAdapter; - - @override - Future findCommentById(int id) async { - return _queryAdapter.query('SELECT * FROM comments WHERE id = ?1', - mapper: (Map row) => Comment( - row['id'] as int, row['author'] as String, - content: row['content'] as String, - createTime: row['create_time'] as String?, - updateTime: row['update_time'] as String?), - arguments: [id]); - } - - @override - Future addComment(Comment c) async { - await _commentInsertionAdapter.insert(c, OnConflictStrategy.abort); - } - - @override - Future removeComment(Comment c) async { - await _commentDeletionAdapter.delete(c); - } -} diff --git a/floor_common/test/integration/type_converter/order_database.g.dart b/floor_common/test/integration/type_converter/order_database.g.dart deleted file mode 100644 index 3746ee41..00000000 --- a/floor_common/test/integration/type_converter/order_database.g.dart +++ /dev/null @@ -1,166 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'order_database.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $OrderDatabaseBuilderContract { - /// Adds migrations to the builder. - $OrderDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $OrderDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorOrderDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $OrderDatabaseBuilderContract databaseBuilder(String name) => - _$OrderDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $OrderDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$OrderDatabaseBuilder(null); -} - -class _$OrderDatabaseBuilder implements $OrderDatabaseBuilderContract { - _$OrderDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $OrderDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $OrderDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$OrderDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$OrderDatabase extends OrderDatabase { - _$OrderDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - OrderDao? _orderDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `Order` (`id` INTEGER NOT NULL, `date` INTEGER NOT NULL, PRIMARY KEY (`id`))'); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - OrderDao get orderDao { - return _orderDaoInstance ??= _$OrderDao(database, changeListener); - } -} - -class _$OrderDao extends OrderDao { - _$OrderDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _orderInsertionAdapter = InsertionAdapter( - database, - 'Order', - (Order item) => { - 'id': item.id, - 'date': _dateTimeConverter.encode(item.date) - }); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _orderInsertionAdapter; - - @override - Future> findOrdersByDate(DateTime date) async { - return _queryAdapter.queryList('SELECT * FROM `Order` WHERE date = ?1', - mapper: (Map row) => Order( - row['id'] as int, _dateTimeConverter.decode(row['date'] as int)), - arguments: [_dateTimeConverter.encode(date)]); - } - - @override - Future> findOrdersByDates(List dates) async { - const offset = 1; - final _sqliteVariablesForDates = - Iterable.generate(dates.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM `Order` WHERE date IN (' + - _sqliteVariablesForDates + - ')', - mapper: (Map row) => Order( - row['id'] as int, _dateTimeConverter.decode(row['date'] as int)), - arguments: [ - ...dates.map((element) => _dateTimeConverter.encode(element)) - ]); - } - - @override - Future insertOrder(Order order) async { - await _orderInsertionAdapter.insert(order, OnConflictStrategy.abort); - } -} - -// ignore_for_file: unused_element -final _dateTimeConverter = DateTimeConverter(); diff --git a/floor_common/test/integration/view/view_test.g.dart b/floor_common/test/integration/view/view_test.g.dart deleted file mode 100644 index b168d05e..00000000 --- a/floor_common/test/integration/view/view_test.g.dart +++ /dev/null @@ -1,521 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'view_test.dart'; - -// ************************************************************************** -// FloorGenerator -// ************************************************************************** - -abstract class $ViewTestDatabaseBuilderContract { - /// Adds migrations to the builder. - $ViewTestDatabaseBuilderContract addMigrations(List migrations); - - /// Adds a database [Callback] to the builder. - $ViewTestDatabaseBuilderContract addCallback(Callback callback); - - /// Creates the database and initializes it. - Future build(); -} - -// ignore: avoid_classes_with_only_static_members -class $FloorViewTestDatabase { - /// Creates a database builder for a persistent database. - /// Once a database is built, you should keep a reference to it and re-use it. - static $ViewTestDatabaseBuilderContract databaseBuilder(String name) => - _$ViewTestDatabaseBuilder(name); - - /// Creates a database builder for an in memory database. - /// Information stored in an in memory database disappears when the process is killed. - /// Once a database is built, you should keep a reference to it and re-use it. - static $ViewTestDatabaseBuilderContract inMemoryDatabaseBuilder() => - _$ViewTestDatabaseBuilder(null); -} - -class _$ViewTestDatabaseBuilder implements $ViewTestDatabaseBuilderContract { - _$ViewTestDatabaseBuilder(this.name); - - final String? name; - - final List _migrations = []; - - Callback? _callback; - - @override - $ViewTestDatabaseBuilderContract addMigrations(List migrations) { - _migrations.addAll(migrations); - return this; - } - - @override - $ViewTestDatabaseBuilderContract addCallback(Callback callback) { - _callback = callback; - return this; - } - - @override - Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; - final database = _$ViewTestDatabase(); - database.database = await database.open( - path, - _migrations, - _callback, - ); - return database; - } -} - -class _$ViewTestDatabase extends ViewTestDatabase { - _$ViewTestDatabase([StreamController? listener]) { - changeListener = listener ?? StreamController.broadcast(); - } - - PersonDao? _personDaoInstance; - - DogDao? _dogDaoInstance; - - NameDao? _nameDaoInstance; - - Future open( - String path, - List migrations, [ - Callback? callback, - ]) async { - final databaseOptions = sqflite.OpenDatabaseOptions( - version: 1, - onConfigure: (database) async { - await database.execute('PRAGMA foreign_keys = ON'); - await callback?.onConfigure?.call(database); - }, - onOpen: (database) async { - await callback?.onOpen?.call(database); - }, - onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); - - await callback?.onUpgrade?.call(database, startVersion, endVersion); - }, - onCreate: (database, version) async { - await database.execute( - 'CREATE TABLE IF NOT EXISTS `person` (`id` INTEGER, `custom_name` TEXT NOT NULL, PRIMARY KEY (`id`))'); - await database.execute( - 'CREATE TABLE IF NOT EXISTS `dog` (`id` INTEGER, `name` TEXT NOT NULL, `nick_name` TEXT NOT NULL, `owner_id` INTEGER NOT NULL, FOREIGN KEY (`owner_id`) REFERENCES `person` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, PRIMARY KEY (`id`))'); - await database.execute( - 'CREATE INDEX `index_person_custom_name` ON `person` (`custom_name`)'); - await database.execute( - 'CREATE VIEW IF NOT EXISTS `names` AS SELECT custom_name as name FROM person UNION SELECT name from dog'); - await database.execute( - 'CREATE VIEW IF NOT EXISTS `multiline_query_names` AS SELECT custom_name as name \n FROM person \n UNION SELECT name from dog\n '); - - await callback?.onCreate?.call(database, version); - }, - ); - return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions); - } - - @override - PersonDao get personDao { - return _personDaoInstance ??= _$PersonDao(database, changeListener); - } - - @override - DogDao get dogDao { - return _dogDaoInstance ??= _$DogDao(database, changeListener); - } - - @override - NameDao get nameDao { - return _nameDaoInstance ??= _$NameDao(database, changeListener); - } -} - -class _$PersonDao extends PersonDao { - _$PersonDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database, changeListener), - _personInsertionAdapter = InsertionAdapter( - database, - 'person', - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener), - _personUpdateAdapter = UpdateAdapter( - database, - 'person', - ['id'], - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener), - _personDeletionAdapter = DeletionAdapter( - database, - 'person', - ['id'], - (Person item) => - {'id': item.id, 'custom_name': item.name}, - changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _personInsertionAdapter; - - final UpdateAdapter _personUpdateAdapter; - - final DeletionAdapter _personDeletionAdapter; - - @override - Future> findAllPersons() async { - return _queryAdapter.queryList('SELECT * FROM person', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String)); - } - - @override - Stream> findAllPersonsAsStream() { - return _queryAdapter.queryListStream('SELECT * FROM person', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - queryableName: 'person', - isView: false); - } - - @override - Future findPersonById(int id) async { - return _queryAdapter.query('SELECT * FROM person WHERE id = ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id]); - } - - @override - Stream findPersonByIdAsStream(int id) { - return _queryAdapter.queryStream('SELECT * FROM person WHERE id = ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id], - queryableName: 'person', - isView: false); - } - - @override - Stream uniqueRecordsCountAsStream() { - return _queryAdapter.queryStream('SELECT DISTINCT COUNT(id) FROM person', - mapper: (Map row) => row.values.first as int, - queryableName: 'person', - isView: false); - } - - @override - Future findPersonByIdAndName( - int id, - String name, - ) async { - return _queryAdapter.query( - 'SELECT * FROM person WHERE id = ?1 AND custom_name = ?2', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [id, name]); - } - - @override - Future> findPersonsWithIds(List ids) async { - const offset = 1; - final _sqliteVariablesForIds = - Iterable.generate(ids.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE id IN (' + _sqliteVariablesForIds + ')', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [...ids]); - } - - @override - Future> findPersonsWithNames(List names) async { - const offset = 1; - final _sqliteVariablesForNames = - Iterable.generate(names.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name IN (' + - _sqliteVariablesForNames + - ')', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [...names]); - } - - @override - Future> findPersonsWithNamesComplex( - int reference, - List names, - List moreNames, - ) async { - int offset = 2; - final _sqliteVariablesForNames = - Iterable.generate(names.length, (i) => '?${i + offset}') - .join(','); - offset += names.length; - final _sqliteVariablesForMoreNames = - Iterable.generate(moreNames.length, (i) => '?${i + offset}') - .join(','); - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name IN (' + - _sqliteVariablesForNames + - ') AND id>=?1 OR custom_name IN (' + - _sqliteVariablesForMoreNames + - ') AND id<=?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [reference, ...names, ...moreNames]); - } - - @override - Future> findPersonsWithNamesLike(String name) async { - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name LIKE ?1', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String), - arguments: [name]); - } - - @override - Future> findPersonsWithEmptyName() async { - return _queryAdapter.queryList( - 'SELECT * FROM person WHERE custom_name == \'\'', - mapper: (Map row) => - Person(row['id'] as int?, row['custom_name'] as String)); - } - - @override - Future deleteAllPersons() async { - await _queryAdapter.queryNoReturn('DELETE FROM person'); - } - - @override - Stream> findAllDogsOfPersonAsStream(int id) { - return _queryAdapter.queryListStream( - 'SELECT * FROM dog WHERE owner_id = ?1', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int), - arguments: [id], - queryableName: 'dog', - isView: false); - } - - @override - Future insertPerson(Person person) async { - await _personInsertionAdapter.insert(person, OnConflictStrategy.replace); - } - - @override - Future insertPersons(List persons) async { - await _personInsertionAdapter.insertList(persons, OnConflictStrategy.abort); - } - - @override - Future insertPersonWithReturn(Person person) { - return _personInsertionAdapter.insertAndReturnId( - person, OnConflictStrategy.abort); - } - - @override - Future> insertPersonsWithReturn(List persons) { - return _personInsertionAdapter.insertListAndReturnIds( - persons, OnConflictStrategy.abort); - } - - @override - Future updatePerson(Person person) async { - await _personUpdateAdapter.update(person, OnConflictStrategy.abort); - } - - @override - Future updatePersons(List persons) async { - await _personUpdateAdapter.updateList(persons, OnConflictStrategy.abort); - } - - @override - Future updatePersonWithReturn(Person person) { - return _personUpdateAdapter.updateAndReturnChangedRows( - person, OnConflictStrategy.abort); - } - - @override - Future updatePersonsWithReturn(List persons) { - return _personUpdateAdapter.updateListAndReturnChangedRows( - persons, OnConflictStrategy.abort); - } - - @override - Future deletePerson(Person person) async { - await _personDeletionAdapter.delete(person); - } - - @override - Future deletePersons(List person) async { - await _personDeletionAdapter.deleteList(person); - } - - @override - Future deletePersonWithReturn(Person person) { - return _personDeletionAdapter.deleteAndReturnChangedRows(person); - } - - @override - Future deletePersonsWithReturn(List persons) { - return _personDeletionAdapter.deleteListAndReturnChangedRows(persons); - } - - @override - Future replacePersons(List persons) async { - if (database is sqflite.Transaction) { - await super.replacePersons(persons); - } else { - await (database as sqflite.Database) - .transaction((transaction) async { - final transactionDatabase = _$ViewTestDatabase(changeListener) - ..database = transaction; - await transactionDatabase.personDao.replacePersons(persons); - }); - } - } - - @override - Future> replacePersonsAndReturn(List persons) async { - if (database is sqflite.Transaction) { - return super.replacePersonsAndReturn(persons); - } else { - return (database as sqflite.Database) - .transaction>((transaction) async { - final transactionDatabase = _$ViewTestDatabase(changeListener) - ..database = transaction; - return transactionDatabase.personDao.replacePersonsAndReturn(persons); - }); - } - } -} - -class _$DogDao extends DogDao { - _$DogDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database), - _dogInsertionAdapter = InsertionAdapter( - database, - 'dog', - (Dog item) => { - 'id': item.id, - 'name': item.name, - 'nick_name': item.nickName, - 'owner_id': item.ownerId - }, - changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - final InsertionAdapter _dogInsertionAdapter; - - @override - Future findDogForPersonId(int id) async { - return _queryAdapter.query('SELECT * FROM dog WHERE owner_id = ?1', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int), - arguments: [id]); - } - - @override - Future> findAllDogs() async { - return _queryAdapter.queryList('SELECT * FROM dog', - mapper: (Map row) => Dog( - row['id'] as int?, - row['name'] as String, - row['nick_name'] as String, - row['owner_id'] as int)); - } - - @override - Future insertDog(Dog dog) async { - await _dogInsertionAdapter.insert(dog, OnConflictStrategy.abort); - } -} - -class _$NameDao extends NameDao { - _$NameDao( - this.database, - this.changeListener, - ) : _queryAdapter = QueryAdapter(database, changeListener); - - final sqflite.DatabaseExecutor database; - - final StreamController changeListener; - - final QueryAdapter _queryAdapter; - - @override - Future> findAllNames() async { - return _queryAdapter.queryList('SELECT * FROM names ORDER BY name ASC', - mapper: (Map row) => Name(row['name'] as String)); - } - - @override - Stream> findAllNamesAsStream() { - return _queryAdapter.queryListStream( - 'SELECT * FROM names ORDER BY name ASC', - mapper: (Map row) => Name(row['name'] as String), - queryableName: 'names', - isView: true); - } - - @override - Future findExactName(String name) async { - return _queryAdapter.query('SELECT * FROM names WHERE name = ?1', - mapper: (Map row) => Name(row['name'] as String), - arguments: [name]); - } - - @override - Future> findNamesLike(String suffix) async { - return _queryAdapter.queryList( - 'SELECT * FROM names WHERE name LIKE ?1 ORDER BY name ASC', - mapper: (Map row) => Name(row['name'] as String), - arguments: [suffix]); - } - - @override - Future> findNamesMatchingBoth( - String prefix, - String suffix, - ) async { - return _queryAdapter.queryList( - 'SELECT * FROM names WHERE name LIKE ?2 AND name LIKE ?1 ORDER BY name ASC', - mapper: (Map row) => Name(row['name'] as String), - arguments: [prefix, suffix]); - } - - @override - Future findMultilineQueryName(String name) async { - return _queryAdapter.query( - 'SELECT * FROM multiline_query_names WHERE name = ?1', - mapper: (Map row) => - MultilineQueryName(row['name'] as String), - arguments: [name]); - } -}