Skip to content

Commit

Permalink
Re-run generator
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Jan 4, 2025
1 parent 0f2fecb commit 68ea6ea
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 223 deletions.
91 changes: 73 additions & 18 deletions docs/lib/snippets/_shared/todo_tables.drift.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ typedef $$TodoItemsTableUpdateCompanionBuilder = i1.TodoItemsCompanion
i0.Value<DateTime?> dueDate,
});

final class $$TodoItemsTableReferences extends i0
.BaseReferences<i0.GeneratedDatabase, i1.$TodoItemsTable, i1.TodoItem> {
$$TodoItemsTableReferences(super.$_db, super.$_table, super.$_typedResult);

static i1.$CategoriesTable _categoryTable(i0.GeneratedDatabase db) =>
i3.ReadDatabaseContainer(db)
.resultSet<i1.$CategoriesTable>('categories')
.createAlias(i0.$_aliasNameGenerator(
i3.ReadDatabaseContainer(db)
.resultSet<i1.$TodoItemsTable>('todo_items')
.category,
i3.ReadDatabaseContainer(db)
.resultSet<i1.$CategoriesTable>('categories')
.id));

i1.$$CategoriesTableProcessedTableManager? get category {
if ($_item.category == null) return null;
final manager = i1
.$$CategoriesTableTableManager(
$_db,
i3.ReadDatabaseContainer($_db)
.resultSet<i1.$CategoriesTable>('categories'))
.filter((f) => f.id($_item.category!));
final item = $_typedResult.readTableOrNull(_categoryTable($_db));
if (item == null) return manager;
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: [item]));
}
}

class $$TodoItemsTableFilterComposer
extends i0.Composer<i0.GeneratedDatabase, i1.$TodoItemsTable> {
$$TodoItemsTableFilterComposer({
Expand Down Expand Up @@ -163,10 +193,7 @@ class $$TodoItemsTableTableManager extends i0.RootTableManager<
i1.$$TodoItemsTableAnnotationComposer,
$$TodoItemsTableCreateCompanionBuilder,
$$TodoItemsTableUpdateCompanionBuilder,
(
i1.TodoItem,
i0.BaseReferences<i0.GeneratedDatabase, i1.$TodoItemsTable, i1.TodoItem>
),
(i1.TodoItem, i1.$$TodoItemsTableReferences),
i1.TodoItem,
i0.PrefetchHooks Function({bool category})> {
$$TodoItemsTableTableManager(
Expand Down Expand Up @@ -209,7 +236,10 @@ class $$TodoItemsTableTableManager extends i0.RootTableManager<
dueDate: dueDate,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.map((e) => (
e.readTable(table),
i1.$$TodoItemsTableReferences(db, table, e)
))
.toList(),
prefetchHooksCallback: null,
));
Expand All @@ -224,10 +254,7 @@ typedef $$TodoItemsTableProcessedTableManager = i0.ProcessedTableManager<
i1.$$TodoItemsTableAnnotationComposer,
$$TodoItemsTableCreateCompanionBuilder,
$$TodoItemsTableUpdateCompanionBuilder,
(
i1.TodoItem,
i0.BaseReferences<i0.GeneratedDatabase, i1.$TodoItemsTable, i1.TodoItem>
),
(i1.TodoItem, i1.$$TodoItemsTableReferences),
i1.TodoItem,
i0.PrefetchHooks Function({bool category})>;
typedef $$CategoriesTableCreateCompanionBuilder = i1.CategoriesCompanion
Expand All @@ -241,6 +268,37 @@ typedef $$CategoriesTableUpdateCompanionBuilder = i1.CategoriesCompanion
i0.Value<String> name,
});

final class $$CategoriesTableReferences extends i0
.BaseReferences<i0.GeneratedDatabase, i1.$CategoriesTable, i1.Category> {
$$CategoriesTableReferences(super.$_db, super.$_table, super.$_typedResult);

static i0.MultiTypedResultKey<i1.$TodoItemsTable, List<i1.TodoItem>>
_todoItemsRefsTable(i0.GeneratedDatabase db) =>
i0.MultiTypedResultKey.fromTable(
i3.ReadDatabaseContainer(db)
.resultSet<i1.$TodoItemsTable>('todo_items'),
aliasName: i0.$_aliasNameGenerator(
i3.ReadDatabaseContainer(db)
.resultSet<i1.$CategoriesTable>('categories')
.id,
i3.ReadDatabaseContainer(db)
.resultSet<i1.$TodoItemsTable>('todo_items')
.category));

i1.$$TodoItemsTableProcessedTableManager get todoItemsRefs {
final manager = i1
.$$TodoItemsTableTableManager(
$_db,
i3.ReadDatabaseContainer($_db)
.resultSet<i1.$TodoItemsTable>('todo_items'))
.filter((f) => f.category.id($_item.id));

final cache = $_typedResult.readTableOrNull(_todoItemsRefsTable($_db));
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: cache));
}
}

class $$CategoriesTableFilterComposer
extends i0.Composer<i0.GeneratedDatabase, i1.$CategoriesTable> {
$$CategoriesTableFilterComposer({
Expand Down Expand Up @@ -344,10 +402,7 @@ class $$CategoriesTableTableManager extends i0.RootTableManager<
i1.$$CategoriesTableAnnotationComposer,
$$CategoriesTableCreateCompanionBuilder,
$$CategoriesTableUpdateCompanionBuilder,
(
i1.Category,
i0.BaseReferences<i0.GeneratedDatabase, i1.$CategoriesTable, i1.Category>
),
(i1.Category, i1.$$CategoriesTableReferences),
i1.Category,
i0.PrefetchHooks Function({bool todoItemsRefs})> {
$$CategoriesTableTableManager(
Expand Down Expand Up @@ -378,7 +433,10 @@ class $$CategoriesTableTableManager extends i0.RootTableManager<
name: name,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.map((e) => (
e.readTable(table),
i1.$$CategoriesTableReferences(db, table, e)
))
.toList(),
prefetchHooksCallback: null,
));
Expand All @@ -393,10 +451,7 @@ typedef $$CategoriesTableProcessedTableManager = i0.ProcessedTableManager<
i1.$$CategoriesTableAnnotationComposer,
$$CategoriesTableCreateCompanionBuilder,
$$CategoriesTableUpdateCompanionBuilder,
(
i1.Category,
i0.BaseReferences<i0.GeneratedDatabase, i1.$CategoriesTable, i1.Category>
),
(i1.Category, i1.$$CategoriesTableReferences),
i1.Category,
i0.PrefetchHooks Function({bool todoItemsRefs})>;
typedef $$UsersTableCreateCompanionBuilder = i1.UsersCompanion Function({
Expand Down
78 changes: 66 additions & 12 deletions docs/lib/snippets/modular/drift/example.drift.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,36 @@ typedef $TodosUpdateCompanionBuilder = i1.TodosCompanion Function({
i0.Value<int?> category,
});

final class $TodosReferences
extends i0.BaseReferences<i0.GeneratedDatabase, i1.Todos, i1.Todo> {
$TodosReferences(super.$_db, super.$_table, super.$_typedResult);

static i1.Categories _categoryTable(i0.GeneratedDatabase db) =>
i2.ReadDatabaseContainer(db)
.resultSet<i1.Categories>('categories')
.createAlias(i0.$_aliasNameGenerator(
i2.ReadDatabaseContainer(db)
.resultSet<i1.Todos>('todos')
.category,
i2.ReadDatabaseContainer(db)
.resultSet<i1.Categories>('categories')
.id));

i1.$CategoriesProcessedTableManager? get category {
if ($_item.category == null) return null;
final manager = i1
.$CategoriesTableManager(
$_db,
i2.ReadDatabaseContainer($_db)
.resultSet<i1.Categories>('categories'))
.filter((f) => f.id($_item.category!));
final item = $_typedResult.readTableOrNull(_categoryTable($_db));
if (item == null) return manager;
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: [item]));
}
}

class $TodosFilterComposer extends i0.Composer<i0.GeneratedDatabase, i1.Todos> {
$TodosFilterComposer({
required super.$db,
Expand Down Expand Up @@ -148,7 +178,7 @@ class $TodosTableManager extends i0.RootTableManager<
i1.$TodosAnnotationComposer,
$TodosCreateCompanionBuilder,
$TodosUpdateCompanionBuilder,
(i1.Todo, i0.BaseReferences<i0.GeneratedDatabase, i1.Todos, i1.Todo>),
(i1.Todo, i1.$TodosReferences),
i1.Todo,
i0.PrefetchHooks Function({bool category})> {
$TodosTableManager(i0.GeneratedDatabase db, i1.Todos table)
Expand Down Expand Up @@ -186,7 +216,8 @@ class $TodosTableManager extends i0.RootTableManager<
category: category,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.map((e) =>
(e.readTable(table), i1.$TodosReferences(db, table, e)))
.toList(),
prefetchHooksCallback: null,
));
Expand All @@ -201,7 +232,7 @@ typedef $TodosProcessedTableManager = i0.ProcessedTableManager<
i1.$TodosAnnotationComposer,
$TodosCreateCompanionBuilder,
$TodosUpdateCompanionBuilder,
(i1.Todo, i0.BaseReferences<i0.GeneratedDatabase, i1.Todos, i1.Todo>),
(i1.Todo, i1.$TodosReferences),
i1.Todo,
i0.PrefetchHooks Function({bool category})>;
typedef $CategoriesCreateCompanionBuilder = i1.CategoriesCompanion Function({
Expand All @@ -213,6 +244,34 @@ typedef $CategoriesUpdateCompanionBuilder = i1.CategoriesCompanion Function({
i0.Value<String> description,
});

final class $CategoriesReferences extends i0
.BaseReferences<i0.GeneratedDatabase, i1.Categories, i1.Category> {
$CategoriesReferences(super.$_db, super.$_table, super.$_typedResult);

static i0.MultiTypedResultKey<i1.Todos, List<i1.Todo>> _todosRefsTable(
i0.GeneratedDatabase db) =>
i0.MultiTypedResultKey.fromTable(
i2.ReadDatabaseContainer(db).resultSet<i1.Todos>('todos'),
aliasName: i0.$_aliasNameGenerator(
i2.ReadDatabaseContainer(db)
.resultSet<i1.Categories>('categories')
.id,
i2.ReadDatabaseContainer(db)
.resultSet<i1.Todos>('todos')
.category));

i1.$TodosProcessedTableManager get todosRefs {
final manager = i1
.$TodosTableManager(
$_db, i2.ReadDatabaseContainer($_db).resultSet<i1.Todos>('todos'))
.filter((f) => f.category.id($_item.id));

final cache = $_typedResult.readTableOrNull(_todosRefsTable($_db));
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: cache));
}
}

class $CategoriesFilterComposer
extends i0.Composer<i0.GeneratedDatabase, i1.Categories> {
$CategoriesFilterComposer({
Expand Down Expand Up @@ -318,10 +377,7 @@ class $CategoriesTableManager extends i0.RootTableManager<
i1.$CategoriesAnnotationComposer,
$CategoriesCreateCompanionBuilder,
$CategoriesUpdateCompanionBuilder,
(
i1.Category,
i0.BaseReferences<i0.GeneratedDatabase, i1.Categories, i1.Category>
),
(i1.Category, i1.$CategoriesReferences),
i1.Category,
i0.PrefetchHooks Function({bool todosRefs})> {
$CategoriesTableManager(i0.GeneratedDatabase db, i1.Categories table)
Expand Down Expand Up @@ -351,7 +407,8 @@ class $CategoriesTableManager extends i0.RootTableManager<
description: description,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.map((e) =>
(e.readTable(table), i1.$CategoriesReferences(db, table, e)))
.toList(),
prefetchHooksCallback: null,
));
Expand All @@ -366,10 +423,7 @@ typedef $CategoriesProcessedTableManager = i0.ProcessedTableManager<
i1.$CategoriesAnnotationComposer,
$CategoriesCreateCompanionBuilder,
$CategoriesUpdateCompanionBuilder,
(
i1.Category,
i0.BaseReferences<i0.GeneratedDatabase, i1.Categories, i1.Category>
),
(i1.Category, i1.$CategoriesReferences),
i1.Category,
i0.PrefetchHooks Function({bool todosRefs})>;

Expand Down
50 changes: 47 additions & 3 deletions docs/lib/snippets/modular/drift/with_existing.drift.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,49 @@ typedef $FriendsUpdateCompanionBuilder = i2.FriendsCompanion Function({
i0.Value<int> rowid,
});

final class $FriendsReferences
extends i0.BaseReferences<i0.GeneratedDatabase, i2.Friends, i2.Friend> {
$FriendsReferences(super.$_db, super.$_table, super.$_typedResult);

static i2.Users _userATable(i0.GeneratedDatabase db) =>
i3.ReadDatabaseContainer(db).resultSet<i2.Users>('users').createAlias(
i0.$_aliasNameGenerator(
i3.ReadDatabaseContainer(db)
.resultSet<i2.Friends>('friends')
.userA,
i3.ReadDatabaseContainer(db).resultSet<i2.Users>('users').id));

i2.$UsersProcessedTableManager get userA {
final manager = i2
.$UsersTableManager(
$_db, i3.ReadDatabaseContainer($_db).resultSet<i2.Users>('users'))
.filter((f) => f.id($_item.userA));
final item = $_typedResult.readTableOrNull(_userATable($_db));
if (item == null) return manager;
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: [item]));
}

static i2.Users _userBTable(i0.GeneratedDatabase db) =>
i3.ReadDatabaseContainer(db).resultSet<i2.Users>('users').createAlias(
i0.$_aliasNameGenerator(
i3.ReadDatabaseContainer(db)
.resultSet<i2.Friends>('friends')
.userB,
i3.ReadDatabaseContainer(db).resultSet<i2.Users>('users').id));

i2.$UsersProcessedTableManager get userB {
final manager = i2
.$UsersTableManager(
$_db, i3.ReadDatabaseContainer($_db).resultSet<i2.Users>('users'))
.filter((f) => f.id($_item.userB));
final item = $_typedResult.readTableOrNull(_userBTable($_db));
if (item == null) return manager;
return i0.ProcessedTableManager(
manager.$state.copyWith(prefetchedData: [item]));
}
}

class $FriendsFilterComposer
extends i0.Composer<i0.GeneratedDatabase, i2.Friends> {
$FriendsFilterComposer({
Expand Down Expand Up @@ -301,7 +344,7 @@ class $FriendsTableManager extends i0.RootTableManager<
i2.$FriendsAnnotationComposer,
$FriendsCreateCompanionBuilder,
$FriendsUpdateCompanionBuilder,
(i2.Friend, i0.BaseReferences<i0.GeneratedDatabase, i2.Friends, i2.Friend>),
(i2.Friend, i2.$FriendsReferences),
i2.Friend,
i0.PrefetchHooks Function({bool userA, bool userB})> {
$FriendsTableManager(i0.GeneratedDatabase db, i2.Friends table)
Expand Down Expand Up @@ -335,7 +378,8 @@ class $FriendsTableManager extends i0.RootTableManager<
rowid: rowid,
),
withReferenceMapper: (p0) => p0
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
.map((e) =>
(e.readTable(table), i2.$FriendsReferences(db, table, e)))
.toList(),
prefetchHooksCallback: null,
));
Expand All @@ -350,7 +394,7 @@ typedef $FriendsProcessedTableManager = i0.ProcessedTableManager<
i2.$FriendsAnnotationComposer,
$FriendsCreateCompanionBuilder,
$FriendsUpdateCompanionBuilder,
(i2.Friend, i0.BaseReferences<i0.GeneratedDatabase, i2.Friends, i2.Friend>),
(i2.Friend, i2.$FriendsReferences),
i2.Friend,
i0.PrefetchHooks Function({bool userA, bool userB})>;

Expand Down
Loading

0 comments on commit 68ea6ea

Please sign in to comment.