Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate modular manager code #2970

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 273 additions & 0 deletions docs/lib/snippets/_shared/todo_tables.drift.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'package:drift/drift.dart' as i0;
import 'package:drift_docs/snippets/_shared/todo_tables.drift.dart' as i1;
import 'package:drift_docs/snippets/_shared/todo_tables.dart' as i2;
import 'package:drift/internal/modular.dart' as i3;

class $TodoItemsTable extends i2.TodoItems
with i0.TableInfo<$TodoItemsTable, i1.TodoItem> {
Expand Down Expand Up @@ -300,6 +301,133 @@ class TodoItemsCompanion extends i0.UpdateCompanion<i1.TodoItem> {
}
}

class $$TodoItemsTableFilterComposer
extends i0.FilterComposer<i0.GeneratedDatabase, i1.$TodoItemsTable> {
$$TodoItemsTableFilterComposer(super.db, super.table);
i0.ColumnFilters<int> get id => i0.ColumnFilters($table.id);
i0.ColumnFilters<String> get title => i0.ColumnFilters($table.title);
i0.ColumnFilters<String> get content => i0.ColumnFilters($table.content);
i0.ColumnFilters<int> get categoryId => i0.ColumnFilters($table.category);
i0.ComposableFilter category(
i0.ComposableFilter Function(i1.$$CategoriesTableFilterComposer f) f) {
return $composeWithJoins(
$db: $db,
$table: $table,
referencedTable: i3.ReadDatabaseContainer($db)
.resultSet<i1.$CategoriesTable>('categories'),
getCurrentColumn: (f) => f.category,
getReferencedColumn: (f) => f.id,
getReferencedComposer: (db, table) =>
i1.$$CategoriesTableFilterComposer(db, table),
builder: f);
}

i0.ColumnFilters<DateTime> get dueDate => i0.ColumnFilters($table.dueDate);
}

class $$TodoItemsTableOrderingComposer
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.$TodoItemsTable> {
$$TodoItemsTableOrderingComposer(super.db, super.table);
i0.ColumnOrderings<int> get id => i0.ColumnOrderings($table.id);
i0.ColumnOrderings<String> get title => i0.ColumnOrderings($table.title);
i0.ColumnOrderings<String> get content => i0.ColumnOrderings($table.content);
i0.ColumnOrderings<int> get categoryId => i0.ColumnOrderings($table.category);
i0.ComposableOrdering category(
i0.ComposableOrdering Function(i1.$$CategoriesTableOrderingComposer o)
o) {
return $composeWithJoins(
$db: $db,
$table: $table,
referencedTable: i3.ReadDatabaseContainer($db)
.resultSet<i1.$CategoriesTable>('categories'),
getCurrentColumn: (f) => f.category,
getReferencedColumn: (f) => f.id,
getReferencedComposer: (db, table) =>
i1.$$CategoriesTableOrderingComposer(db, table),
builder: o);
}

i0.ColumnOrderings<DateTime> get dueDate =>
i0.ColumnOrderings($table.dueDate);
}

class $$TodoItemsTableProcessedTableManager extends i0.ProcessedTableManager<
i0.GeneratedDatabase,
i1.$TodoItemsTable,
i1.TodoItem,
$$TodoItemsTableFilterComposer,
$$TodoItemsTableOrderingComposer,
$$TodoItemsTableProcessedTableManager,
$$TodoItemsTableInsertCompanionBuilder,
$$TodoItemsTableUpdateCompanionBuilder> {
const $$TodoItemsTableProcessedTableManager(super.$state);
}

typedef $$TodoItemsTableInsertCompanionBuilder = i1.TodoItemsCompanion
Function({
i0.Value<int> id,
required String title,
required String content,
i0.Value<int?> category,
i0.Value<DateTime?> dueDate,
});
typedef $$TodoItemsTableUpdateCompanionBuilder = i1.TodoItemsCompanion
Function({
i0.Value<int> id,
i0.Value<String> title,
i0.Value<String> content,
i0.Value<int?> category,
i0.Value<DateTime?> dueDate,
});

class $$TodoItemsTableTableManager extends i0.RootTableManager<
i0.GeneratedDatabase,
i1.$TodoItemsTable,
i1.TodoItem,
$$TodoItemsTableFilterComposer,
$$TodoItemsTableOrderingComposer,
$$TodoItemsTableProcessedTableManager,
$$TodoItemsTableInsertCompanionBuilder,
$$TodoItemsTableUpdateCompanionBuilder> {
$$TodoItemsTableTableManager(
i0.GeneratedDatabase db, i1.$TodoItemsTable table)
: super(i0.TableManagerState(
db: db,
table: table,
filteringComposer: $$TodoItemsTableFilterComposer(db, table),
orderingComposer: $$TodoItemsTableOrderingComposer(db, table),
getChildManagerBuilder: (p0) =>
$$TodoItemsTableProcessedTableManager(p0),
getUpdateCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
i0.Value<String> title = const i0.Value.absent(),
i0.Value<String> content = const i0.Value.absent(),
i0.Value<int?> category = const i0.Value.absent(),
i0.Value<DateTime?> dueDate = const i0.Value.absent(),
}) =>
i1.TodoItemsCompanion(
id: id,
title: title,
content: content,
category: category,
dueDate: dueDate,
),
getInsertCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
required String title,
required String content,
i0.Value<int?> category = const i0.Value.absent(),
i0.Value<DateTime?> dueDate = const i0.Value.absent(),
}) =>
i1.TodoItemsCompanion.insert(
id: id,
title: title,
content: content,
category: category,
dueDate: dueDate,
)));
}

class $CategoriesTable extends i2.Categories
with i0.TableInfo<$CategoriesTable, i1.Category> {
@override
Expand Down Expand Up @@ -471,6 +599,79 @@ class CategoriesCompanion extends i0.UpdateCompanion<i1.Category> {
}
}

class $$CategoriesTableFilterComposer
extends i0.FilterComposer<i0.GeneratedDatabase, i1.$CategoriesTable> {
$$CategoriesTableFilterComposer(super.db, super.table);
i0.ColumnFilters<int> get id => i0.ColumnFilters($table.id);
i0.ColumnFilters<String> get name => i0.ColumnFilters($table.name);
}

class $$CategoriesTableOrderingComposer
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.$CategoriesTable> {
$$CategoriesTableOrderingComposer(super.db, super.table);
i0.ColumnOrderings<int> get id => i0.ColumnOrderings($table.id);
i0.ColumnOrderings<String> get name => i0.ColumnOrderings($table.name);
}

class $$CategoriesTableProcessedTableManager extends i0.ProcessedTableManager<
i0.GeneratedDatabase,
i1.$CategoriesTable,
i1.Category,
$$CategoriesTableFilterComposer,
$$CategoriesTableOrderingComposer,
$$CategoriesTableProcessedTableManager,
$$CategoriesTableInsertCompanionBuilder,
$$CategoriesTableUpdateCompanionBuilder> {
const $$CategoriesTableProcessedTableManager(super.$state);
}

typedef $$CategoriesTableInsertCompanionBuilder = i1.CategoriesCompanion
Function({
i0.Value<int> id,
required String name,
});
typedef $$CategoriesTableUpdateCompanionBuilder = i1.CategoriesCompanion
Function({
i0.Value<int> id,
i0.Value<String> name,
});

class $$CategoriesTableTableManager extends i0.RootTableManager<
i0.GeneratedDatabase,
i1.$CategoriesTable,
i1.Category,
$$CategoriesTableFilterComposer,
$$CategoriesTableOrderingComposer,
$$CategoriesTableProcessedTableManager,
$$CategoriesTableInsertCompanionBuilder,
$$CategoriesTableUpdateCompanionBuilder> {
$$CategoriesTableTableManager(
i0.GeneratedDatabase db, i1.$CategoriesTable table)
: super(i0.TableManagerState(
db: db,
table: table,
filteringComposer: $$CategoriesTableFilterComposer(db, table),
orderingComposer: $$CategoriesTableOrderingComposer(db, table),
getChildManagerBuilder: (p0) =>
$$CategoriesTableProcessedTableManager(p0),
getUpdateCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
i0.Value<String> name = const i0.Value.absent(),
}) =>
i1.CategoriesCompanion(
id: id,
name: name,
),
getInsertCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
required String name,
}) =>
i1.CategoriesCompanion.insert(
id: id,
name: name,
)));
}

class $UsersTable extends i2.Users with i0.TableInfo<$UsersTable, i1.User> {
@override
final i0.GeneratedDatabase attachedDatabase;
Expand Down Expand Up @@ -643,3 +844,75 @@ class UsersCompanion extends i0.UpdateCompanion<i1.User> {
.toString();
}
}

class $$UsersTableFilterComposer
extends i0.FilterComposer<i0.GeneratedDatabase, i1.$UsersTable> {
$$UsersTableFilterComposer(super.db, super.table);
i0.ColumnFilters<int> get id => i0.ColumnFilters($table.id);
i0.ColumnFilters<DateTime> get birthDate =>
i0.ColumnFilters($table.birthDate);
}

class $$UsersTableOrderingComposer
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.$UsersTable> {
$$UsersTableOrderingComposer(super.db, super.table);
i0.ColumnOrderings<int> get id => i0.ColumnOrderings($table.id);
i0.ColumnOrderings<DateTime> get birthDate =>
i0.ColumnOrderings($table.birthDate);
}

class $$UsersTableProcessedTableManager extends i0.ProcessedTableManager<
i0.GeneratedDatabase,
i1.$UsersTable,
i1.User,
$$UsersTableFilterComposer,
$$UsersTableOrderingComposer,
$$UsersTableProcessedTableManager,
$$UsersTableInsertCompanionBuilder,
$$UsersTableUpdateCompanionBuilder> {
const $$UsersTableProcessedTableManager(super.$state);
}

typedef $$UsersTableInsertCompanionBuilder = i1.UsersCompanion Function({
i0.Value<int> id,
required DateTime birthDate,
});
typedef $$UsersTableUpdateCompanionBuilder = i1.UsersCompanion Function({
i0.Value<int> id,
i0.Value<DateTime> birthDate,
});

class $$UsersTableTableManager extends i0.RootTableManager<
i0.GeneratedDatabase,
i1.$UsersTable,
i1.User,
$$UsersTableFilterComposer,
$$UsersTableOrderingComposer,
$$UsersTableProcessedTableManager,
$$UsersTableInsertCompanionBuilder,
$$UsersTableUpdateCompanionBuilder> {
$$UsersTableTableManager(i0.GeneratedDatabase db, i1.$UsersTable table)
: super(i0.TableManagerState(
db: db,
table: table,
filteringComposer: $$UsersTableFilterComposer(db, table),
orderingComposer: $$UsersTableOrderingComposer(db, table),
getChildManagerBuilder: (p0) =>
$$UsersTableProcessedTableManager(p0),
getUpdateCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
i0.Value<DateTime> birthDate = const i0.Value.absent(),
}) =>
i1.UsersCompanion(
id: id,
birthDate: birthDate,
),
getInsertCompanionBuilder: ({
i0.Value<int> id = const i0.Value.absent(),
required DateTime birthDate,
}) =>
i1.UsersCompanion.insert(
id: id,
birthDate: birthDate,
)));
}
Loading
Loading