// GENERATED CODE - DO NOT MODIFY BY HAND part of 'database.dart'; // ************************************************************************** // MoorGenerator // ************************************************************************** // ignore_for_file: unnecessary_brace_in_string_interps, unnecessary_this class TodoEntry extends DataClass implements Insertable { final int id; final String content; final DateTime targetDate; final int category; TodoEntry( {@required this.id, @required this.content, this.targetDate, this.category}); factory TodoEntry.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); final dateTimeType = db.typeSystem.forDartType(); return TodoEntry( id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), content: stringType.mapFromDatabaseResponse(data['${effectivePrefix}content']), targetDate: dateTimeType .mapFromDatabaseResponse(data['${effectivePrefix}target_date']), category: intType.mapFromDatabaseResponse(data['${effectivePrefix}category']), ); } factory TodoEntry.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return TodoEntry( id: serializer.fromJson(json['id']), content: serializer.fromJson(json['content']), targetDate: serializer.fromJson(json['targetDate']), category: serializer.fromJson(json['category']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'content': serializer.toJson(content), 'targetDate': serializer.toJson(targetDate), 'category': serializer.toJson(category), }; } @override TodosCompanion createCompanion(bool nullToAbsent) { return TodosCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), content: content == null && nullToAbsent ? const Value.absent() : Value(content), targetDate: targetDate == null && nullToAbsent ? const Value.absent() : Value(targetDate), category: category == null && nullToAbsent ? const Value.absent() : Value(category), ); } TodoEntry copyWith( {int id, String content, DateTime targetDate, int category}) => TodoEntry( id: id ?? this.id, content: content ?? this.content, targetDate: targetDate ?? this.targetDate, category: category ?? this.category, ); @override String toString() { return (StringBuffer('TodoEntry(') ..write('id: $id, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') ..write('category: $category') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc(id.hashCode, $mrjc(content.hashCode, $mrjc(targetDate.hashCode, category.hashCode)))); @override bool operator ==(other) => identical(this, other) || (other is TodoEntry && other.id == this.id && other.content == this.content && other.targetDate == this.targetDate && other.category == this.category); } class TodosCompanion extends UpdateCompanion { final Value id; final Value content; final Value targetDate; final Value category; const TodosCompanion({ this.id = const Value.absent(), this.content = const Value.absent(), this.targetDate = const Value.absent(), this.category = const Value.absent(), }); TodosCompanion.insert({ this.id = const Value.absent(), @required String content, this.targetDate = const Value.absent(), this.category = const Value.absent(), }) : content = Value(content); TodosCompanion copyWith( {Value id, Value content, Value targetDate, Value category}) { return TodosCompanion( id: id ?? this.id, content: content ?? this.content, targetDate: targetDate ?? this.targetDate, category: category ?? this.category, ); } } class $TodosTable extends Todos with TableInfo<$TodosTable, TodoEntry> { final GeneratedDatabase _db; final String _alias; $TodosTable(this._db, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); GeneratedIntColumn _id; @override GeneratedIntColumn get id => _id ??= _constructId(); GeneratedIntColumn _constructId() { return GeneratedIntColumn('id', $tableName, false, hasAutoIncrement: true, declaredAsPrimaryKey: true); } final VerificationMeta _contentMeta = const VerificationMeta('content'); GeneratedTextColumn _content; @override GeneratedTextColumn get content => _content ??= _constructContent(); GeneratedTextColumn _constructContent() { return GeneratedTextColumn( 'content', $tableName, false, ); } final VerificationMeta _targetDateMeta = const VerificationMeta('targetDate'); GeneratedDateTimeColumn _targetDate; @override GeneratedDateTimeColumn get targetDate => _targetDate ??= _constructTargetDate(); GeneratedDateTimeColumn _constructTargetDate() { return GeneratedDateTimeColumn( 'target_date', $tableName, true, ); } final VerificationMeta _categoryMeta = const VerificationMeta('category'); GeneratedIntColumn _category; @override GeneratedIntColumn get category => _category ??= _constructCategory(); GeneratedIntColumn _constructCategory() { return GeneratedIntColumn('category', $tableName, true, $customConstraints: 'NULLABLE REFERENCES categories(id)'); } @override List get $columns => [id, content, targetDate, category]; @override $TodosTable get asDslTable => this; @override String get $tableName => _alias ?? 'todos'; @override final String actualTableName = 'todos'; @override VerificationContext validateIntegrity(TodosCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.id.present) { context.handle(_idMeta, id.isAcceptableValue(d.id.value, _idMeta)); } else if (id.isRequired && isInserting) { context.missing(_idMeta); } if (d.content.present) { context.handle(_contentMeta, content.isAcceptableValue(d.content.value, _contentMeta)); } else if (content.isRequired && isInserting) { context.missing(_contentMeta); } if (d.targetDate.present) { context.handle(_targetDateMeta, targetDate.isAcceptableValue(d.targetDate.value, _targetDateMeta)); } else if (targetDate.isRequired && isInserting) { context.missing(_targetDateMeta); } if (d.category.present) { context.handle(_categoryMeta, category.isAcceptableValue(d.category.value, _categoryMeta)); } else if (category.isRequired && isInserting) { context.missing(_categoryMeta); } return context; } @override Set get $primaryKey => {id}; @override TodoEntry map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return TodoEntry.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(TodosCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.content.present) { map['content'] = Variable(d.content.value); } if (d.targetDate.present) { map['target_date'] = Variable(d.targetDate.value); } if (d.category.present) { map['category'] = Variable(d.category.value); } return map; } @override $TodosTable createAlias(String alias) { return $TodosTable(_db, alias); } } class Category extends DataClass implements Insertable { final int id; final String description; Category({@required this.id, @required this.description}); factory Category.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); return Category( id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), description: stringType.mapFromDatabaseResponse(data['${effectivePrefix}desc']), ); } factory Category.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return Category( id: serializer.fromJson(json['id']), description: serializer.fromJson(json['description']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'description': serializer.toJson(description), }; } @override CategoriesCompanion createCompanion(bool nullToAbsent) { return CategoriesCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), description: description == null && nullToAbsent ? const Value.absent() : Value(description), ); } Category copyWith({int id, String description}) => Category( id: id ?? this.id, description: description ?? this.description, ); @override String toString() { return (StringBuffer('Category(') ..write('id: $id, ') ..write('description: $description') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc(id.hashCode, description.hashCode)); @override bool operator ==(other) => identical(this, other) || (other is Category && other.id == this.id && other.description == this.description); } class CategoriesCompanion extends UpdateCompanion { final Value id; final Value description; const CategoriesCompanion({ this.id = const Value.absent(), this.description = const Value.absent(), }); CategoriesCompanion.insert({ this.id = const Value.absent(), @required String description, }) : description = Value(description); CategoriesCompanion copyWith({Value id, Value description}) { return CategoriesCompanion( id: id ?? this.id, description: description ?? this.description, ); } } class $CategoriesTable extends Categories with TableInfo<$CategoriesTable, Category> { final GeneratedDatabase _db; final String _alias; $CategoriesTable(this._db, [this._alias]); final VerificationMeta _idMeta = const VerificationMeta('id'); GeneratedIntColumn _id; @override GeneratedIntColumn get id => _id ??= _constructId(); GeneratedIntColumn _constructId() { return GeneratedIntColumn('id', $tableName, false, hasAutoIncrement: true, declaredAsPrimaryKey: true); } final VerificationMeta _descriptionMeta = const VerificationMeta('description'); GeneratedTextColumn _description; @override GeneratedTextColumn get description => _description ??= _constructDescription(); GeneratedTextColumn _constructDescription() { return GeneratedTextColumn( 'desc', $tableName, false, ); } @override List get $columns => [id, description]; @override $CategoriesTable get asDslTable => this; @override String get $tableName => _alias ?? 'categories'; @override final String actualTableName = 'categories'; @override VerificationContext validateIntegrity(CategoriesCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.id.present) { context.handle(_idMeta, id.isAcceptableValue(d.id.value, _idMeta)); } else if (id.isRequired && isInserting) { context.missing(_idMeta); } if (d.description.present) { context.handle(_descriptionMeta, description.isAcceptableValue(d.description.value, _descriptionMeta)); } else if (description.isRequired && isInserting) { context.missing(_descriptionMeta); } return context; } @override Set get $primaryKey => {id}; @override Category map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return Category.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(CategoriesCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.description.present) { map['desc'] = Variable(d.description.value); } return map; } @override $CategoriesTable createAlias(String alias) { return $CategoriesTable(_db, alias); } } abstract class _$Database extends GeneratedDatabase { _$Database(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e); $TodosTable _todos; $TodosTable get todos => _todos ??= $TodosTable(this); $CategoriesTable _categories; $CategoriesTable get categories => _categories ??= $CategoriesTable(this); Future _resetCategory(int var1) { return customUpdate( 'UPDATE todos SET category = NULL WHERE category = ?', variables: [Variable.withInt(var1)], updates: {todos}, ); } CategoriesWithCountResult _rowToCategoriesWithCountResult(QueryRow row) { return CategoriesWithCountResult( id: row.readInt('id'), desc: row.readString('desc'), amount: row.readInt('amount'), ); } Selectable _categoriesWithCount() { return customSelectQuery( 'SELECT\n c.id,\n c.desc,\n (SELECT COUNT(*) FROM todos WHERE category = c.id) AS amount\n FROM categories c\n UNION ALL\n SELECT null, null, (SELECT COUNT(*) FROM todos WHERE category IS NULL)', variables: [], readsFrom: {categories, todos}).map(_rowToCategoriesWithCountResult); } @override List get allTables => [todos, categories]; } class CategoriesWithCountResult { final int id; final String desc; final int amount; CategoriesWithCountResult({ this.id, this.desc, this.amount, }); }