mirror of https://github.com/AMT-Cheif/drift.git
Merge pull request #605 from friebetill/develop
Add toString to companions
This commit is contained in:
commit
46a573ba7c
|
@ -127,6 +127,15 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('CategoriesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('description: $description')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $CategoriesTable extends Categories
|
||||
|
@ -371,6 +380,17 @@ class RecipesCompanion extends UpdateCompanion<Recipe> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('RecipesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('title: $title, ')
|
||||
..write('instructions: $instructions, ')
|
||||
..write('category: $category')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $RecipesTable extends Recipes with TableInfo<$RecipesTable, Recipe> {
|
||||
|
@ -615,6 +635,16 @@ class IngredientsCompanion extends UpdateCompanion<Ingredient> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('IngredientsCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('name: $name, ')
|
||||
..write('caloriesPer100g: $caloriesPer100g')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $IngredientsTable extends Ingredients
|
||||
|
@ -858,6 +888,16 @@ class IngredientInRecipesCompanion extends UpdateCompanion<IngredientInRecipe> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('IngredientInRecipesCompanion(')
|
||||
..write('recipe: $recipe, ')
|
||||
..write('ingredient: $ingredient, ')
|
||||
..write('amountInGrams: $amountInGrams')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $IngredientInRecipesTable extends IngredientInRecipes
|
||||
|
|
|
@ -122,6 +122,9 @@ class Value<T> {
|
|||
const Value.absent()
|
||||
: value = null,
|
||||
present = false;
|
||||
|
||||
@override
|
||||
String toString() => present ? 'Value($value)' : 'Value.absent()';
|
||||
}
|
||||
|
||||
/// Serializer responsible for mapping atomic types from and to json.
|
||||
|
|
|
@ -199,6 +199,17 @@ class ConfigCompanion extends UpdateCompanion<Config> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('ConfigCompanion(')
|
||||
..write('configKey: $configKey, ')
|
||||
..write('configValue: $configValue, ')
|
||||
..write('syncState: $syncState, ')
|
||||
..write('syncStateImplicit: $syncStateImplicit')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigTable extends Table with TableInfo<ConfigTable, Config> {
|
||||
|
@ -407,6 +418,15 @@ class WithDefaultsCompanion extends UpdateCompanion<WithDefault> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('WithDefaultsCompanion(')
|
||||
..write('a: $a, ')
|
||||
..write('b: $b')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class WithDefaults extends Table with TableInfo<WithDefaults, WithDefault> {
|
||||
|
@ -564,6 +584,14 @@ class NoIdsCompanion extends UpdateCompanion<NoId> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('NoIdsCompanion(')
|
||||
..write('payload: $payload')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class NoIds extends Table with TableInfo<NoIds, NoId> {
|
||||
|
@ -759,6 +787,16 @@ class WithConstraintsCompanion extends UpdateCompanion<WithConstraint> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('WithConstraintsCompanion(')
|
||||
..write('a: $a, ')
|
||||
..write('b: $b, ')
|
||||
..write('c: $c')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class WithConstraints extends Table
|
||||
|
@ -1012,6 +1050,17 @@ class MytableCompanion extends UpdateCompanion<MytableData> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('MytableCompanion(')
|
||||
..write('someid: $someid, ')
|
||||
..write('sometext: $sometext, ')
|
||||
..write('somebool: $somebool, ')
|
||||
..write('somedate: $somedate')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class Mytable extends Table with TableInfo<Mytable, MytableData> {
|
||||
|
@ -1242,6 +1291,16 @@ class EmailCompanion extends UpdateCompanion<EMail> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('EmailCompanion(')
|
||||
..write('sender: $sender, ')
|
||||
..write('title: $title, ')
|
||||
..write('body: $body')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class Email extends Table
|
||||
|
|
|
@ -217,6 +217,18 @@ class TodosTableCompanion extends UpdateCompanion<TodoEntry> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('TodosTableCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('title: $title, ')
|
||||
..write('content: $content, ')
|
||||
..write('targetDate: $targetDate, ')
|
||||
..write('category: $category')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $TodosTableTable extends TodosTable
|
||||
|
@ -484,6 +496,16 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('CategoriesCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('description: $description, ')
|
||||
..write('priority: $priority')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $CategoriesTable extends Categories
|
||||
|
@ -773,6 +795,18 @@ class UsersCompanion extends UpdateCompanion<User> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('UsersCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('name: $name, ')
|
||||
..write('isAwesome: $isAwesome, ')
|
||||
..write('profilePicture: $profilePicture, ')
|
||||
..write('creationTime: $creationTime')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
||||
|
@ -1006,6 +1040,15 @@ class SharedTodosCompanion extends UpdateCompanion<SharedTodo> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('SharedTodosCompanion(')
|
||||
..write('todo: $todo, ')
|
||||
..write('user: $user')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $SharedTodosTable extends SharedTodos
|
||||
|
@ -1239,6 +1282,16 @@ class TableWithoutPKCompanion extends UpdateCompanion<TableWithoutPKData> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('TableWithoutPKCompanion(')
|
||||
..write('notReallyAnId: $notReallyAnId, ')
|
||||
..write('someFloat: $someFloat, ')
|
||||
..write('custom: $custom')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $TableWithoutPKTable extends TableWithoutPK
|
||||
|
@ -1447,6 +1500,15 @@ class PureDefaultsCompanion extends UpdateCompanion<PureDefault> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('PureDefaultsCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('txt: $txt')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $PureDefaultsTable extends PureDefaults
|
||||
|
|
|
@ -23,6 +23,7 @@ class UpdateCompanionWriter {
|
|||
|
||||
_writeCopyWith();
|
||||
_writeToColumnsOverride();
|
||||
_writeToString();
|
||||
|
||||
_buffer.write('}\n');
|
||||
}
|
||||
|
@ -179,4 +180,33 @@ class UpdateCompanionWriter {
|
|||
|
||||
_buffer.write('return map; \n}\n');
|
||||
}
|
||||
|
||||
void _writeToString() {
|
||||
/*
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('Category(')
|
||||
..write('id: $id, ')
|
||||
..write('description: $description')
|
||||
..write(')'))
|
||||
.toString();
|
||||
*/
|
||||
|
||||
_buffer
|
||||
..write('@override\nString toString() {\n')
|
||||
..write('return (StringBuffer('
|
||||
"'${table.getNameForCompanionClass(scope.options)}(')");
|
||||
|
||||
for (var i = 0; i < table.columns.length; i++) {
|
||||
final column = table.columns[i];
|
||||
final dartGetterName = column.dartGetterName;
|
||||
|
||||
_buffer.write("..write('$dartGetterName: \$$dartGetterName");
|
||||
if (i != table.columns.length - 1) _buffer.write(', ');
|
||||
|
||||
_buffer.write("')");
|
||||
}
|
||||
|
||||
_buffer..write("..write(')')).toString();")..write('\}\n');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue