mirror of https://github.com/AMT-Cheif/drift.git
Formatting, fixing tests
This commit is contained in:
parent
2b24684abb
commit
0de6005ad7
|
@ -154,7 +154,7 @@ abstract class GeneratedDatabase extends DatabaseConnectionUser
|
|||
GeneratedDatabase(SqlTypeSystem types, QueryExecutor executor,
|
||||
{StreamQueryStore streamStore})
|
||||
: super(types, executor, streamQueries: streamStore) {
|
||||
executor.databaseInfo = this;
|
||||
executor?.databaseInfo = this;
|
||||
}
|
||||
|
||||
/// Creates a migrator with the provided query executor. We sometimes can't
|
||||
|
|
|
@ -26,6 +26,19 @@ class TodoEntry {
|
|||
category: intType.mapFromDatabaseResponse(data['category']),
|
||||
);
|
||||
}
|
||||
TodoEntry copyWith(
|
||||
{int id,
|
||||
String title,
|
||||
String content,
|
||||
DateTime targetDate,
|
||||
int category}) =>
|
||||
TodoEntry(
|
||||
id: id ?? this.id,
|
||||
title: title ?? this.title,
|
||||
content: content ?? this.content,
|
||||
targetDate: targetDate ?? this.targetDate,
|
||||
category: category ?? this.category,
|
||||
);
|
||||
@override
|
||||
int get hashCode =>
|
||||
((((id.hashCode) * 31 + title.hashCode) * 31 + content.hashCode) * 31 +
|
||||
|
@ -43,10 +56,10 @@ class TodoEntry {
|
|||
other.category == category);
|
||||
}
|
||||
|
||||
class _$TodosTableTable extends TodosTable
|
||||
class $TodosTableTable extends TodosTable
|
||||
implements TableInfo<TodosTable, TodoEntry> {
|
||||
final GeneratedDatabase _db;
|
||||
_$TodosTableTable(this._db);
|
||||
$TodosTableTable(this._db);
|
||||
@override
|
||||
GeneratedIntColumn get id =>
|
||||
GeneratedIntColumn('id', false, hasAutoIncrement: true);
|
||||
|
@ -125,6 +138,10 @@ class Category {
|
|||
description: stringType.mapFromDatabaseResponse(data['`desc`']),
|
||||
);
|
||||
}
|
||||
Category copyWith({int id, String description}) => Category(
|
||||
id: id ?? this.id,
|
||||
description: description ?? this.description,
|
||||
);
|
||||
@override
|
||||
int get hashCode => (id.hashCode) * 31 + description.hashCode;
|
||||
@override
|
||||
|
@ -133,10 +150,10 @@ class Category {
|
|||
(other is Category && other.id == id && other.description == description);
|
||||
}
|
||||
|
||||
class _$CategoriesTable extends Categories
|
||||
class $CategoriesTable extends Categories
|
||||
implements TableInfo<Categories, Category> {
|
||||
final GeneratedDatabase _db;
|
||||
_$CategoriesTable(this._db);
|
||||
$CategoriesTable(this._db);
|
||||
@override
|
||||
GeneratedIntColumn get id =>
|
||||
GeneratedIntColumn('id', false, hasAutoIncrement: true);
|
||||
|
@ -190,6 +207,11 @@ class User {
|
|||
isAwesome: boolType.mapFromDatabaseResponse(data['is_awesome']),
|
||||
);
|
||||
}
|
||||
User copyWith({int id, String name, bool isAwesome}) => User(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
isAwesome: isAwesome ?? this.isAwesome,
|
||||
);
|
||||
@override
|
||||
int get hashCode =>
|
||||
((id.hashCode) * 31 + name.hashCode) * 31 + isAwesome.hashCode;
|
||||
|
@ -202,9 +224,9 @@ class User {
|
|||
other.isAwesome == isAwesome);
|
||||
}
|
||||
|
||||
class _$UsersTable extends Users implements TableInfo<Users, User> {
|
||||
class $UsersTable extends Users implements TableInfo<Users, User> {
|
||||
final GeneratedDatabase _db;
|
||||
_$UsersTable(this._db);
|
||||
$UsersTable(this._db);
|
||||
@override
|
||||
GeneratedIntColumn get id =>
|
||||
GeneratedIntColumn('id', false, hasAutoIncrement: true);
|
||||
|
@ -254,9 +276,9 @@ class _$UsersTable extends Users implements TableInfo<Users, User> {
|
|||
|
||||
abstract class _$TodoDb extends GeneratedDatabase {
|
||||
_$TodoDb(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e);
|
||||
_$TodosTableTable get todosTable => _$TodosTableTable(this);
|
||||
_$CategoriesTable get categories => _$CategoriesTable(this);
|
||||
_$UsersTable get users => _$UsersTable(this);
|
||||
$TodosTableTable get todosTable => $TodosTableTable(this);
|
||||
$CategoriesTable get categories => $CategoriesTable(this);
|
||||
$UsersTable get users => $UsersTable(this);
|
||||
@override
|
||||
List<TableInfo> get allTables => [todosTable, categories, users];
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ void main() {
|
|||
.write(TodoEntry(title: 'Updated title', category: 3));
|
||||
|
||||
verify(executor.runUpdate(
|
||||
'UPDATE todos SET title = ? category = ?;', ['Updated title', 3]));
|
||||
'UPDATE todos SET title = ?, category = ?;', ['Updated title', 3]));
|
||||
});
|
||||
|
||||
test('with a WHERE clause', () async {
|
||||
|
@ -49,7 +49,9 @@ void main() {
|
|||
test('are issued when data was changed', () async {
|
||||
when(executor.runUpdate(any, any)).thenAnswer((_) => Future.value(3));
|
||||
|
||||
await db.update(db.todosTable).write(TodoEntry());
|
||||
await db.update(db.todosTable).write(TodoEntry(
|
||||
content: 'Updated content',
|
||||
));
|
||||
|
||||
verify(streamQueries.handleTableUpdates('todos'));
|
||||
});
|
||||
|
|
|
@ -109,7 +109,7 @@ class DataClassWriter {
|
|||
buffer.write('}) => $dataClassName(');
|
||||
|
||||
for (var column in table.columns) {
|
||||
// we also have a method parameter called getter, so we can use
|
||||
// we also have a method parameter called like the getter, so we can use
|
||||
// field: field ?? this.field
|
||||
final getter = column.dartGetterName;
|
||||
buffer.write('$getter: $getter ?? this.$getter,');
|
||||
|
|
Loading…
Reference in New Issue