mirror of https://github.com/AMT-Cheif/drift.git
Avoid dynamic when overriding ==
This commit is contained in:
parent
2a2f73a821
commit
41eb6f4181
|
@ -141,7 +141,7 @@ class User extends DataClass implements Insertable<User> {
|
|||
$mrjc(birthDate.hashCode,
|
||||
$mrjc(profilePicture.hashCode, preferences.hashCode)))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is User &&
|
||||
other.id == this.id &&
|
||||
|
@ -430,7 +430,7 @@ class Friendship extends DataClass implements Insertable<Friendship> {
|
|||
int get hashCode => $mrjf($mrjc(firstUser.hashCode,
|
||||
$mrjc(secondUser.hashCode, reallyGoodFriends.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Friendship &&
|
||||
other.firstUser == this.firstUser &&
|
||||
|
@ -676,7 +676,7 @@ class FriendshipsOfResult {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(reallyGoodFriends.hashCode, user.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is FriendshipsOfResult &&
|
||||
other.reallyGoodFriends == this.reallyGoodFriends &&
|
||||
|
|
|
@ -69,7 +69,7 @@ class Entrie extends DataClass implements Insertable<Entrie> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(id.hashCode, value.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Entrie && other.id == this.id && other.value == this.value);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class User extends DataClass implements Insertable<User> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(id.hashCode, name.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is User && other.id == this.id && other.name == this.name);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class Category extends DataClass implements Insertable<Category> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(id.hashCode, description.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Category &&
|
||||
other.id == this.id &&
|
||||
|
@ -299,7 +299,7 @@ class Recipe extends DataClass implements Insertable<Recipe> {
|
|||
int get hashCode => $mrjf($mrjc(id.hashCode,
|
||||
$mrjc(title.hashCode, $mrjc(instructions.hashCode, category.hashCode))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Recipe &&
|
||||
other.id == this.id &&
|
||||
|
@ -555,7 +555,7 @@ class Ingredient extends DataClass implements Insertable<Ingredient> {
|
|||
int get hashCode =>
|
||||
$mrjf($mrjc(id.hashCode, $mrjc(name.hashCode, caloriesPer100g.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Ingredient &&
|
||||
other.id == this.id &&
|
||||
|
@ -792,7 +792,7 @@ class IngredientInRecipe extends DataClass
|
|||
int get hashCode => $mrjf($mrjc(
|
||||
recipe.hashCode, $mrjc(ingredient.hashCode, amountInGrams.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is IngredientInRecipe &&
|
||||
other.recipe == this.recipe &&
|
||||
|
@ -993,7 +993,7 @@ class TotalWeightResult extends CustomResultSet {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(title.hashCode, totalWeight.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is TotalWeightResult &&
|
||||
other.title == this.title &&
|
||||
|
|
|
@ -122,7 +122,7 @@ class Config extends DataClass implements Insertable<Config> {
|
|||
$mrjc(configValue.hashCode,
|
||||
$mrjc(syncState.hashCode, syncStateImplicit.hashCode))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Config &&
|
||||
other.configKey == this.configKey &&
|
||||
|
@ -367,7 +367,7 @@ class WithDefault extends DataClass implements Insertable<WithDefault> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(a.hashCode, b.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is WithDefault && other.a == this.a && other.b == this.b);
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ class WithConstraint extends DataClass implements Insertable<WithConstraint> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(a.hashCode, $mrjc(b.hashCode, c.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is WithConstraint &&
|
||||
other.a == this.a &&
|
||||
|
@ -904,7 +904,7 @@ class MytableData extends DataClass implements Insertable<MytableData> {
|
|||
$mrjc(
|
||||
sometext.hashCode, $mrjc(isInserting.hashCode, somedate.hashCode))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is MytableData &&
|
||||
other.someid == this.someid &&
|
||||
|
@ -1151,7 +1151,7 @@ class EMail extends DataClass implements Insertable<EMail> {
|
|||
int get hashCode =>
|
||||
$mrjf($mrjc(sender.hashCode, $mrjc(title.hashCode, body.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is EMail &&
|
||||
other.sender == this.sender &&
|
||||
|
@ -1368,7 +1368,7 @@ class WeirdData extends DataClass implements Insertable<WeirdData> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(sqlClass.hashCode, textColumn.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is WeirdData &&
|
||||
other.sqlClass == this.sqlClass &&
|
||||
|
@ -1722,7 +1722,7 @@ class JsonResult extends CustomResultSet {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(key.hashCode, value.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is JsonResult &&
|
||||
other.key == this.key &&
|
||||
|
@ -1750,7 +1750,7 @@ class MultipleResult extends CustomResultSet {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(a.hashCode, $mrjc(b.hashCode, c.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is MultipleResult &&
|
||||
other.a == this.a &&
|
||||
|
@ -1789,7 +1789,7 @@ class ReadRowIdResult extends CustomResultSet {
|
|||
$mrjc(configValue.hashCode,
|
||||
$mrjc(syncState.hashCode, syncStateImplicit.hashCode)))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is ReadRowIdResult &&
|
||||
other.rowid == this.rowid &&
|
||||
|
@ -1828,7 +1828,7 @@ class ReadViewResult extends CustomResultSet {
|
|||
$mrjc(configValue.hashCode,
|
||||
$mrjc(syncState.hashCode, syncStateImplicit.hashCode))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is ReadViewResult &&
|
||||
other.configKey == this.configKey &&
|
||||
|
|
|
@ -128,7 +128,7 @@ class TodoEntry extends DataClass implements Insertable<TodoEntry> {
|
|||
$mrjc(content.hashCode,
|
||||
$mrjc(targetDate.hashCode, category.hashCode)))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is TodoEntry &&
|
||||
other.id == this.id &&
|
||||
|
@ -414,7 +414,7 @@ class Category extends DataClass implements Insertable<Category> {
|
|||
int get hashCode =>
|
||||
$mrjf($mrjc(id.hashCode, $mrjc(description.hashCode, priority.hashCode)));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Category &&
|
||||
other.id == this.id &&
|
||||
|
@ -668,7 +668,7 @@ class User extends DataClass implements Insertable<User> {
|
|||
$mrjc(isAwesome.hashCode,
|
||||
$mrjc(profilePicture.hashCode, creationTime.hashCode)))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is User &&
|
||||
other.id == this.id &&
|
||||
|
@ -938,7 +938,7 @@ class SharedTodo extends DataClass implements Insertable<SharedTodo> {
|
|||
@override
|
||||
int get hashCode => $mrjf($mrjc(todo.hashCode, user.hashCode));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is SharedTodo &&
|
||||
other.todo == this.todo &&
|
||||
|
@ -1283,7 +1283,7 @@ class PureDefault extends DataClass implements Insertable<PureDefault> {
|
|||
@override
|
||||
int get hashCode => $mrjf(txt.hashCode);
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) || (other is PureDefault && other.txt == this.txt);
|
||||
}
|
||||
|
||||
|
@ -1489,7 +1489,7 @@ class AllTodosWithCategoryResult extends CustomResultSet {
|
|||
$mrjc(category.hashCode,
|
||||
$mrjc(catId.hashCode, catDesc.hashCode)))))));
|
||||
@override
|
||||
bool operator ==(dynamic other) =>
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is AllTodosWithCategoryResult &&
|
||||
other.id == this.id &&
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//@dart=2.9
|
||||
/// Writes a operator == override for a class consisting of the [fields] into
|
||||
/// the buffer provided by [into].
|
||||
void overrideEquals(
|
||||
Iterable<String> fields, String className, StringBuffer into) {
|
||||
into
|
||||
..write('@override\nbool operator ==(dynamic other) => ')
|
||||
..write('@override\nbool operator ==(Object other) => ')
|
||||
..write('identical(this, other) || (other is $className');
|
||||
|
||||
if (fields.isNotEmpty) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//@dart=2.9
|
||||
import 'package:moor_generator/src/writer/utils/override_equals.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
@ -9,7 +8,7 @@ void main() {
|
|||
|
||||
expect(
|
||||
buffer.toString(),
|
||||
'@override\nbool operator ==(dynamic other) => '
|
||||
'@override\nbool operator ==(Object other) => '
|
||||
'identical(this, other) || (other is Foo);\n');
|
||||
});
|
||||
|
||||
|
@ -19,7 +18,7 @@ void main() {
|
|||
|
||||
expect(
|
||||
buffer.toString(),
|
||||
'@override\nbool operator ==(dynamic other) => '
|
||||
'@override\nbool operator ==(Object other) => '
|
||||
'identical(this, other) || (other is Foo && '
|
||||
'other.a == this.a && other.b == this.b && other.c == this.c);\n');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue