diff --git a/drift/test/extensions/geopoly_integration_test.g.dart b/drift/test/extensions/geopoly_integration_test.g.dart index a307c839..1ece9211 100644 --- a/drift/test/extensions/geopoly_integration_test.g.dart +++ b/drift/test/extensions/geopoly_integration_test.g.dart @@ -206,6 +206,8 @@ class GeopolyTestCompanion extends UpdateCompanion { abstract class _$_GeopolyTestDatabase extends GeneratedDatabase { _$_GeopolyTestDatabase(QueryExecutor e) : super(e); + _$_GeopolyTestDatabaseManager get managers => + _$_GeopolyTestDatabaseManager(this); late final GeopolyTest geopolyTest = GeopolyTest(this); Selectable area(int var1) { return customSelect( @@ -224,3 +226,86 @@ abstract class _$_GeopolyTestDatabase extends GeneratedDatabase { @override List get allSchemaEntities => [geopolyTest]; } + +class $GeopolyTestFilterComposer + extends FilterComposer<_$_GeopolyTestDatabase, GeopolyTest> { + $GeopolyTestFilterComposer(super.db, super.table); + ColumnFilters get shape => ColumnFilters($table.shape); + ColumnFilters get a => ColumnFilters($table.a); +} + +class $GeopolyTestOrderingComposer + extends OrderingComposer<_$_GeopolyTestDatabase, GeopolyTest> { + $GeopolyTestOrderingComposer(super.db, super.table); + ColumnOrderings get shape => ColumnOrderings($table.shape); + ColumnOrderings get a => ColumnOrderings($table.a); +} + +class $GeopolyTestProcessedTableManager extends ProcessedTableManager< + _$_GeopolyTestDatabase, + GeopolyTest, + GeopolyTestData, + $GeopolyTestFilterComposer, + $GeopolyTestOrderingComposer, + $GeopolyTestProcessedTableManager, + $GeopolyTestInsertCompanionBuilder, + $GeopolyTestUpdateCompanionBuilder> { + const $GeopolyTestProcessedTableManager(super.$state); +} + +typedef $GeopolyTestInsertCompanionBuilder = GeopolyTestCompanion Function({ + Value shape, + Value a, + Value rowid, +}); +typedef $GeopolyTestUpdateCompanionBuilder = GeopolyTestCompanion Function({ + Value shape, + Value a, + Value rowid, +}); + +class $GeopolyTestTableManager extends RootTableManager< + _$_GeopolyTestDatabase, + GeopolyTest, + GeopolyTestData, + $GeopolyTestFilterComposer, + $GeopolyTestOrderingComposer, + $GeopolyTestProcessedTableManager, + $GeopolyTestInsertCompanionBuilder, + $GeopolyTestUpdateCompanionBuilder> { + $GeopolyTestTableManager(_$_GeopolyTestDatabase db, GeopolyTest table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: $GeopolyTestFilterComposer(db, table), + orderingComposer: $GeopolyTestOrderingComposer(db, table), + getChildManagerBuilder: (p0) => + $GeopolyTestProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + Value shape = const Value.absent(), + Value a = const Value.absent(), + Value rowid = const Value.absent(), + }) => + GeopolyTestCompanion( + shape: shape, + a: a, + rowid: rowid, + ), + getInsertCompanionBuilder: ({ + Value shape = const Value.absent(), + Value a = const Value.absent(), + Value rowid = const Value.absent(), + }) => + GeopolyTestCompanion.insert( + shape: shape, + a: a, + rowid: rowid, + ))); +} + +class _$_GeopolyTestDatabaseManager { + final _$_GeopolyTestDatabase _db; + _$_GeopolyTestDatabaseManager(this._db); + $GeopolyTestTableManager get geopolyTest => + $GeopolyTestTableManager(_db, _db.geopolyTest); +} diff --git a/drift_dev/lib/src/backends/build/drift_builder.dart b/drift_dev/lib/src/backends/build/drift_builder.dart index 987c4c55..6369eb0a 100644 --- a/drift_dev/lib/src/backends/build/drift_builder.dart +++ b/drift_dev/lib/src/backends/build/drift_builder.dart @@ -13,6 +13,7 @@ import '../../writer/database_writer.dart'; import '../../writer/drift_accessor_writer.dart'; import '../../writer/function_stubs_writer.dart'; import '../../writer/import_manager.dart'; +import '../../writer/manager_writer.dart'; import '../../writer/modules.dart'; import '../../writer/tables/table_writer.dart'; import '../../writer/tables/view_writer.dart'; @@ -294,6 +295,10 @@ class _DriftBuildRun { if (result is DriftTable) { TableWriter(result, writer.child()).writeInto(); + + final scope = writer.child(); + final manager = ManagerWriter(scope, scope, '')..addTable(result); + manager.writeTableManagers(); } else if (result is DriftView) { ViewWriter(result, writer.child(), null).write(); } else if (result is DriftTrigger) { diff --git a/drift_dev/lib/src/writer/database_writer.dart b/drift_dev/lib/src/writer/database_writer.dart index 1d1b00e4..d3c6a502 100644 --- a/drift_dev/lib/src/writer/database_writer.dart +++ b/drift_dev/lib/src/writer/database_writer.dart @@ -148,14 +148,20 @@ class DatabaseWriter { } } - // Write the main database manager & all the managers for tables + // Write the main database manager and, if we're doing a monolithic build, + // the manager classes for involved tables. if (scope.options.generateManager) { final managerWriter = ManagerWriter(scope.child(), dbScope, dbClassName); for (var table in elements.whereType()) { managerWriter.addTable(table); } - managerWriter.write(); - // Add getter for the manager to the database class + if (!scope.generationOptions.isModular) { + managerWriter.writeTableManagers(); + } + + // Write main class for managers and reference it in a getter from the + // database class. + managerWriter.writeMainClass(); firstLeaf.writeln(managerWriter.managerGetter); } diff --git a/drift_dev/lib/src/writer/manager_writer.dart b/drift_dev/lib/src/writer/manager_writer.dart index 2aa2f319..8464dde2 100644 --- a/drift_dev/lib/src/writer/manager_writer.dart +++ b/drift_dev/lib/src/writer/manager_writer.dart @@ -230,12 +230,14 @@ class _TableManagerWriter { /// The name of the filter composer class /// /// E.G `UserFilterComposer` - String get filterComposer => '\$${table.entityInfoName}FilterComposer'; + AnnotatedDartCode get filterComposer => + scope.generatedElement(table, '\$${table.entityInfoName}FilterComposer'); - /// The name of the filter composer class + /// The name of the ordering composer class /// /// E.G `UserOrderingComposer` - String get orderingComposer => '\$${table.entityInfoName}OrderingComposer'; + AnnotatedDartCode get orderingComposer => scope.generatedElement( + table, '\$${table.entityInfoName}OrderingComposer'); /// The name of the processed table manager class /// @@ -246,7 +248,7 @@ class _TableManagerWriter { /// The name of the root table manager class /// /// E.G `UserTableManager` - String get rootTableManager => '\$${table.entityInfoName}TableManager'; + String get rootTableManager => ManagerWriter._rootManagerName(table); /// Name of the typedef for the insertCompanionBuilder /// @@ -440,8 +442,7 @@ class _TableManagerWriter { .firstOrNull ?.otherColumn; if (referencedCol != null && referencedCol.owner is DriftTable) { - final referencedTable = tables.firstWhere( - (t) => t.entityInfoName == referencedCol.owner.entityInfoName); + final referencedTable = referencedCol.owner as DriftTable; return (referencedTable, referencedCol); } return null; @@ -507,12 +508,14 @@ class _TableManagerWriter { c.filters.add(_ReferencedFilterWriter(c.fieldGetter, fieldGetter: c.fieldGetter, referencedColumnGetter: referencedColumnNames.fieldGetter, - referencedFilterComposer: referencedTableNames.filterComposer, + referencedFilterComposer: + scope.dartCode(referencedTableNames.filterComposer), referencedTableField: referencedTableField)); c.orderings.add(_ReferencedOrderingWriter(c.fieldGetter, fieldGetter: c.fieldGetter, referencedColumnGetter: referencedColumnNames.fieldGetter, - referencedOrderingComposer: referencedTableNames.orderingComposer, + referencedOrderingComposer: + scope.dartCode(referencedTableNames.orderingComposer), referencedTableField: referencedTableField)); } columns.add(c); @@ -536,7 +539,8 @@ class _TableManagerWriter { backRefFilters.add(_ReferencedFilterWriter(filterName, fieldGetter: reference.$2.nameInDart, referencedColumnGetter: referencedColumnNames.fieldGetter, - referencedFilterComposer: referencedTableNames.filterComposer, + referencedFilterComposer: + scope.dartCode(referencedTableNames.filterComposer), referencedTableField: referencedTableField)); } } @@ -604,8 +608,15 @@ class ManagerWriter { return '$databaseManagerName get managers => $databaseManagerName(this);'; } - /// Write the manager to a provider [TextEmitter] - void write() { + static String _rootManagerName(DriftTable table) { + return '\$${table.entityInfoName}TableManager'; + } + + AnnotatedDartCode _referenceRootManager(DriftTable table) { + return _scope.generatedElement(table, _rootManagerName(table)); + } + + void writeTableManagers() { final leaf = _scope.leaf(); // create the manager class for each table @@ -620,19 +631,29 @@ class ManagerWriter { tableWriters.removeWhere((t) => t.hasCustomRowClass); // Write each tables manager to the leaf and append the getter to the main manager - final tableManagerGetters = StringBuffer(); for (var table in tableWriters) { table.writeManager(leaf); - tableManagerGetters.writeln( - "${table.rootTableManager} get ${table.table.dbGetterName} => ${table.rootTableManager}(_db, _db.${table.table.dbGetterName});"); } + } - // Write the main manager class + /// Writes the main manager class referencing the generated classes for each + /// table using a getter. + void writeMainClass() { + final leaf = _scope.leaf(); leaf ..writeln('class $databaseManagerName{') ..writeln('final $_dbClassName _db;') - ..writeln('$databaseManagerName(this._db);') - ..writeln(tableManagerGetters) - ..writeln('}'); + ..writeln('$databaseManagerName(this._db);'); + + for (final table in _addedTables) { + if (!table.hasExistingRowClass) { + final type = leaf.dartCode(_referenceRootManager(table)); + + leaf.writeln( + '$type get ${table.dbGetterName} => $type(_db, _db.${table.dbGetterName});'); + } + } + + leaf.writeln('}'); } } diff --git a/examples/modular/lib/database.drift.dart b/examples/modular/lib/database.drift.dart index dbc4198b..2508d04c 100644 --- a/examples/modular/lib/database.drift.dart +++ b/examples/modular/lib/database.drift.dart @@ -10,6 +10,7 @@ import 'package:drift/internal/modular.dart' as i7; abstract class $Database extends i0.GeneratedDatabase { $Database(i0.QueryExecutor e) : super(e); + $DatabaseManager get managers => $DatabaseManager(this); late final i1.Users users = i1.Users(this); late final i2.Posts posts = i2.Posts(this); late final i3.SearchInPosts searchInPosts = i3.SearchInPosts(this); @@ -69,3 +70,15 @@ abstract class $Database extends i0.GeneratedDatabase { i0.DriftDatabaseOptions get options => const i0.DriftDatabaseOptions(storeDateTimeAsText: true); } + +class $DatabaseManager { + final $Database _db; + $DatabaseManager(this._db); + i1.$UsersTableManager get users => i1.$UsersTableManager(_db, _db.users); + i2.$PostsTableManager get posts => i2.$PostsTableManager(_db, _db.posts); + i3.$SearchInPostsTableManager get searchInPosts => + i3.$SearchInPostsTableManager(_db, _db.searchInPosts); + i2.$LikesTableManager get likes => i2.$LikesTableManager(_db, _db.likes); + i1.$FollowsTableManager get follows => + i1.$FollowsTableManager(_db, _db.follows); +} diff --git a/examples/modular/lib/src/posts.drift.dart b/examples/modular/lib/src/posts.drift.dart index 24bea9b9..e6f6afc0 100644 --- a/examples/modular/lib/src/posts.drift.dart +++ b/examples/modular/lib/src/posts.drift.dart @@ -1,6 +1,8 @@ // ignore_for_file: type=lint import 'package:drift/drift.dart' as i0; import 'package:modular/src/posts.drift.dart' as i1; +import 'package:drift/internal/modular.dart' as i2; +import 'package:modular/src/users.drift.dart' as i3; class Posts extends i0.Table with i0.TableInfo { @override @@ -215,6 +217,111 @@ class PostsCompanion extends i0.UpdateCompanion { } } +class $PostsFilterComposer + extends i0.FilterComposer { + $PostsFilterComposer(super.db, super.table); + i0.ColumnFilters get id => i0.ColumnFilters($table.id); + i0.ColumnFilters get authorId => i0.ColumnFilters($table.author); + i0.ComposableFilter author( + i0.ComposableFilter Function(i3.$UsersFilterComposer f) f) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.author, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i3.$UsersFilterComposer(db, table), + builder: f); + } + + i0.ColumnFilters get content => i0.ColumnFilters($table.content); +} + +class $PostsOrderingComposer + extends i0.OrderingComposer { + $PostsOrderingComposer(super.db, super.table); + i0.ColumnOrderings get id => i0.ColumnOrderings($table.id); + i0.ColumnOrderings get authorId => i0.ColumnOrderings($table.author); + i0.ComposableOrdering author( + i0.ComposableOrdering Function(i3.$UsersOrderingComposer o) o) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.author, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i3.$UsersOrderingComposer(db, table), + builder: o); + } + + i0.ColumnOrderings get content => i0.ColumnOrderings($table.content); +} + +class $PostsProcessedTableManager extends i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.Posts, + i1.Post, + $PostsFilterComposer, + $PostsOrderingComposer, + $PostsProcessedTableManager, + $PostsInsertCompanionBuilder, + $PostsUpdateCompanionBuilder> { + const $PostsProcessedTableManager(super.$state); +} + +typedef $PostsInsertCompanionBuilder = i1.PostsCompanion Function({ + i0.Value id, + required int author, + i0.Value content, +}); +typedef $PostsUpdateCompanionBuilder = i1.PostsCompanion Function({ + i0.Value id, + i0.Value author, + i0.Value content, +}); + +class $PostsTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.Posts, + i1.Post, + $PostsFilterComposer, + $PostsOrderingComposer, + $PostsProcessedTableManager, + $PostsInsertCompanionBuilder, + $PostsUpdateCompanionBuilder> { + $PostsTableManager(i0.GeneratedDatabase db, i1.Posts table) + : super(i0.TableManagerState( + db: db, + table: table, + filteringComposer: $PostsFilterComposer(db, table), + orderingComposer: $PostsOrderingComposer(db, table), + getChildManagerBuilder: (p0) => $PostsProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + i0.Value id = const i0.Value.absent(), + i0.Value author = const i0.Value.absent(), + i0.Value content = const i0.Value.absent(), + }) => + i1.PostsCompanion( + id: id, + author: author, + content: content, + ), + getInsertCompanionBuilder: ({ + i0.Value id = const i0.Value.absent(), + required int author, + i0.Value content = const i0.Value.absent(), + }) => + i1.PostsCompanion.insert( + id: id, + author: author, + content: content, + ))); +} + class Likes extends i0.Table with i0.TableInfo { @override final i0.GeneratedDatabase attachedDatabase; @@ -403,3 +510,132 @@ class LikesCompanion extends i0.UpdateCompanion { .toString(); } } + +class $LikesFilterComposer + extends i0.FilterComposer { + $LikesFilterComposer(super.db, super.table); + i0.ColumnFilters get postId => i0.ColumnFilters($table.post); + i0.ComposableFilter post( + i0.ComposableFilter Function(i1.$PostsFilterComposer f) f) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('posts'), + getCurrentColumn: (f) => f.post, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$PostsFilterComposer(db, table), + builder: f); + } + + i0.ColumnFilters get likedById => i0.ColumnFilters($table.likedBy); + i0.ComposableFilter likedBy( + i0.ComposableFilter Function(i3.$UsersFilterComposer f) f) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.likedBy, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i3.$UsersFilterComposer(db, table), + builder: f); + } +} + +class $LikesOrderingComposer + extends i0.OrderingComposer { + $LikesOrderingComposer(super.db, super.table); + i0.ColumnOrderings get postId => i0.ColumnOrderings($table.post); + i0.ComposableOrdering post( + i0.ComposableOrdering Function(i1.$PostsOrderingComposer o) o) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('posts'), + getCurrentColumn: (f) => f.post, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$PostsOrderingComposer(db, table), + builder: o); + } + + i0.ColumnOrderings get likedById => i0.ColumnOrderings($table.likedBy); + i0.ComposableOrdering likedBy( + i0.ComposableOrdering Function(i3.$UsersOrderingComposer o) o) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i2.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.likedBy, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i3.$UsersOrderingComposer(db, table), + builder: o); + } +} + +class $LikesProcessedTableManager extends i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.Likes, + i1.Like, + $LikesFilterComposer, + $LikesOrderingComposer, + $LikesProcessedTableManager, + $LikesInsertCompanionBuilder, + $LikesUpdateCompanionBuilder> { + const $LikesProcessedTableManager(super.$state); +} + +typedef $LikesInsertCompanionBuilder = i1.LikesCompanion Function({ + required int post, + required int likedBy, + i0.Value rowid, +}); +typedef $LikesUpdateCompanionBuilder = i1.LikesCompanion Function({ + i0.Value post, + i0.Value likedBy, + i0.Value rowid, +}); + +class $LikesTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.Likes, + i1.Like, + $LikesFilterComposer, + $LikesOrderingComposer, + $LikesProcessedTableManager, + $LikesInsertCompanionBuilder, + $LikesUpdateCompanionBuilder> { + $LikesTableManager(i0.GeneratedDatabase db, i1.Likes table) + : super(i0.TableManagerState( + db: db, + table: table, + filteringComposer: $LikesFilterComposer(db, table), + orderingComposer: $LikesOrderingComposer(db, table), + getChildManagerBuilder: (p0) => $LikesProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + i0.Value post = const i0.Value.absent(), + i0.Value likedBy = const i0.Value.absent(), + i0.Value rowid = const i0.Value.absent(), + }) => + i1.LikesCompanion( + post: post, + likedBy: likedBy, + rowid: rowid, + ), + getInsertCompanionBuilder: ({ + required int post, + required int likedBy, + i0.Value rowid = const i0.Value.absent(), + }) => + i1.LikesCompanion.insert( + post: post, + likedBy: likedBy, + rowid: rowid, + ))); +} diff --git a/examples/modular/lib/src/search.drift.dart b/examples/modular/lib/src/search.drift.dart index 35949ae8..8ce359b7 100644 --- a/examples/modular/lib/src/search.drift.dart +++ b/examples/modular/lib/src/search.drift.dart @@ -204,6 +204,84 @@ class SearchInPostsCompanion extends i0.UpdateCompanion { } } +class $SearchInPostsFilterComposer + extends i0.FilterComposer { + $SearchInPostsFilterComposer(super.db, super.table); + i0.ColumnFilters get author => i0.ColumnFilters($table.author); + i0.ColumnFilters get content => i0.ColumnFilters($table.content); +} + +class $SearchInPostsOrderingComposer + extends i0.OrderingComposer { + $SearchInPostsOrderingComposer(super.db, super.table); + i0.ColumnOrderings get author => i0.ColumnOrderings($table.author); + i0.ColumnOrderings get content => i0.ColumnOrderings($table.content); +} + +class $SearchInPostsProcessedTableManager extends i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.SearchInPosts, + i1.SearchInPost, + $SearchInPostsFilterComposer, + $SearchInPostsOrderingComposer, + $SearchInPostsProcessedTableManager, + $SearchInPostsInsertCompanionBuilder, + $SearchInPostsUpdateCompanionBuilder> { + const $SearchInPostsProcessedTableManager(super.$state); +} + +typedef $SearchInPostsInsertCompanionBuilder = i1.SearchInPostsCompanion + Function({ + required String author, + required String content, + i0.Value rowid, +}); +typedef $SearchInPostsUpdateCompanionBuilder = i1.SearchInPostsCompanion + Function({ + i0.Value author, + i0.Value content, + i0.Value rowid, +}); + +class $SearchInPostsTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.SearchInPosts, + i1.SearchInPost, + $SearchInPostsFilterComposer, + $SearchInPostsOrderingComposer, + $SearchInPostsProcessedTableManager, + $SearchInPostsInsertCompanionBuilder, + $SearchInPostsUpdateCompanionBuilder> { + $SearchInPostsTableManager(i0.GeneratedDatabase db, i1.SearchInPosts table) + : super(i0.TableManagerState( + db: db, + table: table, + filteringComposer: $SearchInPostsFilterComposer(db, table), + orderingComposer: $SearchInPostsOrderingComposer(db, table), + getChildManagerBuilder: (p0) => + $SearchInPostsProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + i0.Value author = const i0.Value.absent(), + i0.Value content = const i0.Value.absent(), + i0.Value rowid = const i0.Value.absent(), + }) => + i1.SearchInPostsCompanion( + author: author, + content: content, + rowid: rowid, + ), + getInsertCompanionBuilder: ({ + required String author, + required String content, + i0.Value rowid = const i0.Value.absent(), + }) => + i1.SearchInPostsCompanion.insert( + author: author, + content: content, + rowid: rowid, + ))); +} + i0.Trigger get postsInsert => i0.Trigger( 'CREATE TRIGGER posts_insert AFTER INSERT ON posts BEGIN INSERT INTO search_in_posts ("rowid", author, content) VALUES (new.id, new.author, new.content);END', 'posts_insert'); diff --git a/examples/modular/lib/src/users.drift.dart b/examples/modular/lib/src/users.drift.dart index ccacf892..ffae1959 100644 --- a/examples/modular/lib/src/users.drift.dart +++ b/examples/modular/lib/src/users.drift.dart @@ -3,6 +3,7 @@ import 'package:drift/drift.dart' as i0; import 'package:modular/src/users.drift.dart' as i1; import 'package:modular/src/preferences.dart' as i2; import 'dart:typed_data' as i3; +import 'package:drift/internal/modular.dart' as i4; class Users extends i0.Table with i0.TableInfo { @override @@ -313,6 +314,106 @@ class UsersCompanion extends i0.UpdateCompanion { } } +class $UsersFilterComposer + extends i0.FilterComposer { + $UsersFilterComposer(super.db, super.table); + i0.ColumnFilters get id => i0.ColumnFilters($table.id); + i0.ColumnFilters get name => i0.ColumnFilters($table.name); + i0.ColumnFilters get biography => i0.ColumnFilters($table.biography); + i0.ColumnFilters get preferencesValue => + i0.ColumnFilters($table.preferences); + i0.ColumnWithTypeConverterFilters + get preferences => i0.ColumnWithTypeConverterFilters($table.preferences); + i0.ColumnFilters get profilePicture => + i0.ColumnFilters($table.profilePicture); +} + +class $UsersOrderingComposer + extends i0.OrderingComposer { + $UsersOrderingComposer(super.db, super.table); + i0.ColumnOrderings get id => i0.ColumnOrderings($table.id); + i0.ColumnOrderings get name => i0.ColumnOrderings($table.name); + i0.ColumnOrderings get biography => + i0.ColumnOrderings($table.biography); + i0.ColumnOrderings get preferences => + i0.ColumnOrderings($table.preferences); + i0.ColumnOrderings get profilePicture => + i0.ColumnOrderings($table.profilePicture); +} + +class $UsersProcessedTableManager extends i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.Users, + i1.User, + $UsersFilterComposer, + $UsersOrderingComposer, + $UsersProcessedTableManager, + $UsersInsertCompanionBuilder, + $UsersUpdateCompanionBuilder> { + const $UsersProcessedTableManager(super.$state); +} + +typedef $UsersInsertCompanionBuilder = i1.UsersCompanion Function({ + i0.Value id, + required String name, + i0.Value biography, + i0.Value preferences, + i0.Value profilePicture, +}); +typedef $UsersUpdateCompanionBuilder = i1.UsersCompanion Function({ + i0.Value id, + i0.Value name, + i0.Value biography, + i0.Value preferences, + i0.Value profilePicture, +}); + +class $UsersTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.Users, + i1.User, + $UsersFilterComposer, + $UsersOrderingComposer, + $UsersProcessedTableManager, + $UsersInsertCompanionBuilder, + $UsersUpdateCompanionBuilder> { + $UsersTableManager(i0.GeneratedDatabase db, i1.Users table) + : super(i0.TableManagerState( + db: db, + table: table, + filteringComposer: $UsersFilterComposer(db, table), + orderingComposer: $UsersOrderingComposer(db, table), + getChildManagerBuilder: (p0) => $UsersProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + i0.Value id = const i0.Value.absent(), + i0.Value name = const i0.Value.absent(), + i0.Value biography = const i0.Value.absent(), + i0.Value preferences = const i0.Value.absent(), + i0.Value profilePicture = const i0.Value.absent(), + }) => + i1.UsersCompanion( + id: id, + name: name, + biography: biography, + preferences: preferences, + profilePicture: profilePicture, + ), + getInsertCompanionBuilder: ({ + i0.Value id = const i0.Value.absent(), + required String name, + i0.Value biography = const i0.Value.absent(), + i0.Value preferences = const i0.Value.absent(), + i0.Value profilePicture = const i0.Value.absent(), + }) => + i1.UsersCompanion.insert( + id: id, + name: name, + biography: biography, + preferences: preferences, + profilePicture: profilePicture, + ))); +} + i0.Index get usersName => i0.Index('users_name', 'CREATE INDEX users_name ON users (name)'); @@ -510,6 +611,135 @@ class FollowsCompanion extends i0.UpdateCompanion { } } +class $FollowsFilterComposer + extends i0.FilterComposer { + $FollowsFilterComposer(super.db, super.table); + i0.ColumnFilters get followedId => i0.ColumnFilters($table.followed); + i0.ComposableFilter followed( + i0.ComposableFilter Function(i1.$UsersFilterComposer f) f) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i4.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.followed, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$UsersFilterComposer(db, table), + builder: f); + } + + i0.ColumnFilters get followerId => i0.ColumnFilters($table.follower); + i0.ComposableFilter follower( + i0.ComposableFilter Function(i1.$UsersFilterComposer f) f) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i4.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.follower, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$UsersFilterComposer(db, table), + builder: f); + } +} + +class $FollowsOrderingComposer + extends i0.OrderingComposer { + $FollowsOrderingComposer(super.db, super.table); + i0.ColumnOrderings get followedId => i0.ColumnOrderings($table.followed); + i0.ComposableOrdering followed( + i0.ComposableOrdering Function(i1.$UsersOrderingComposer o) o) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i4.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.followed, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$UsersOrderingComposer(db, table), + builder: o); + } + + i0.ColumnOrderings get followerId => i0.ColumnOrderings($table.follower); + i0.ComposableOrdering follower( + i0.ComposableOrdering Function(i1.$UsersOrderingComposer o) o) { + return $composeWithJoins( + $db: $db, + $table: $table, + referencedTable: + i4.ReadDatabaseContainer($db).resultSet('users'), + getCurrentColumn: (f) => f.follower, + getReferencedColumn: (f) => f.id, + getReferencedComposer: (db, table) => + i1.$UsersOrderingComposer(db, table), + builder: o); + } +} + +class $FollowsProcessedTableManager extends i0.ProcessedTableManager< + i0.GeneratedDatabase, + i1.Follows, + i1.Follow, + $FollowsFilterComposer, + $FollowsOrderingComposer, + $FollowsProcessedTableManager, + $FollowsInsertCompanionBuilder, + $FollowsUpdateCompanionBuilder> { + const $FollowsProcessedTableManager(super.$state); +} + +typedef $FollowsInsertCompanionBuilder = i1.FollowsCompanion Function({ + required int followed, + required int follower, + i0.Value rowid, +}); +typedef $FollowsUpdateCompanionBuilder = i1.FollowsCompanion Function({ + i0.Value followed, + i0.Value follower, + i0.Value rowid, +}); + +class $FollowsTableManager extends i0.RootTableManager< + i0.GeneratedDatabase, + i1.Follows, + i1.Follow, + $FollowsFilterComposer, + $FollowsOrderingComposer, + $FollowsProcessedTableManager, + $FollowsInsertCompanionBuilder, + $FollowsUpdateCompanionBuilder> { + $FollowsTableManager(i0.GeneratedDatabase db, i1.Follows table) + : super(i0.TableManagerState( + db: db, + table: table, + filteringComposer: $FollowsFilterComposer(db, table), + orderingComposer: $FollowsOrderingComposer(db, table), + getChildManagerBuilder: (p0) => $FollowsProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + i0.Value followed = const i0.Value.absent(), + i0.Value follower = const i0.Value.absent(), + i0.Value rowid = const i0.Value.absent(), + }) => + i1.FollowsCompanion( + followed: followed, + follower: follower, + rowid: rowid, + ), + getInsertCompanionBuilder: ({ + required int followed, + required int follower, + i0.Value rowid = const i0.Value.absent(), + }) => + i1.FollowsCompanion.insert( + followed: followed, + follower: follower, + rowid: rowid, + ))); +} + class PopularUser extends i0.DataClass { final int id; final String name;