// 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']), ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (!nullToAbsent || id != null) { map['id'] = Variable(id); } if (!nullToAbsent || content != null) { map['content'] = Variable(content); } if (!nullToAbsent || targetDate != null) { map['target_date'] = Variable(targetDate); } if (!nullToAbsent || category != null) { map['category'] = Variable(category); } return map; } TodosCompanion toCompanion(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), ); } factory TodoEntry.fromJson(Map json, {ValueSerializer serializer}) { serializer ??= moorRuntimeOptions.defaultSerializer; 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}) { serializer ??= moorRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'content': serializer.toJson(content), 'targetDate': serializer.toJson(targetDate), 'category': serializer.toJson(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 ==(dynamic 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); static Insertable custom({ Expression id, Expression content, Expression targetDate, Expression category, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (content != null) 'content': content, if (targetDate != null) 'target_date': targetDate, if (category != null) 'category': category, }); } 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, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (id.present) { map['id'] = Variable(id.value); } if (content.present) { map['content'] = Variable(content.value); } if (targetDate.present) { map['target_date'] = Variable(targetDate.value); } if (category.present) { map['category'] = Variable(category.value); } return map; } @override String toString() { return (StringBuffer('TodosCompanion(') ..write('id: $id, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') ..write('category: $category') ..write(')')) .toString(); } } 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(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); if (data.containsKey('id')) { context.handle(_idMeta, id.isAcceptableOrUnknown(data['id'], _idMeta)); } if (data.containsKey('content')) { context.handle(_contentMeta, content.isAcceptableOrUnknown(data['content'], _contentMeta)); } else if (isInserting) { context.missing(_contentMeta); } if (data.containsKey('target_date')) { context.handle( _targetDateMeta, targetDate.isAcceptableOrUnknown( data['target_date'], _targetDateMeta)); } if (data.containsKey('category')) { context.handle(_categoryMeta, category.isAcceptableOrUnknown(data['category'], _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 $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']), ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (!nullToAbsent || id != null) { map['id'] = Variable(id); } if (!nullToAbsent || description != null) { map['desc'] = Variable(description); } return map; } CategoriesCompanion toCompanion(bool nullToAbsent) { return CategoriesCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), description: description == null && nullToAbsent ? const Value.absent() : Value(description), ); } factory Category.fromJson(Map json, {ValueSerializer serializer}) { serializer ??= moorRuntimeOptions.defaultSerializer; return Category( id: serializer.fromJson(json['id']), description: serializer.fromJson(json['description']), ); } @override Map toJson({ValueSerializer serializer}) { serializer ??= moorRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'description': serializer.toJson(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 ==(dynamic 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); static Insertable custom({ Expression id, Expression description, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (description != null) 'desc': description, }); } CategoriesCompanion copyWith({Value id, Value description}) { return CategoriesCompanion( id: id ?? this.id, description: description ?? this.description, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (id.present) { map['id'] = Variable(id.value); } if (description.present) { map['desc'] = Variable(description.value); } return map; } @override String toString() { return (StringBuffer('CategoriesCompanion(') ..write('id: $id, ') ..write('description: $description') ..write(')')) .toString(); } } 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(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); if (data.containsKey('id')) { context.handle(_idMeta, id.isAcceptableOrUnknown(data['id'], _idMeta)); } if (data.containsKey('desc')) { context.handle(_descriptionMeta, description.isAcceptableOrUnknown(data['desc'], _descriptionMeta)); } else if (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 $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(var1)], updates: {todos}, updateKind: UpdateKind.update, ); } Selectable _categoriesWithCount() { return customSelect( '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((QueryRow row) { return CategoriesWithCountResult( id: row.read('id'), desc: row.read('desc'), amount: row.read('amount'), ); }); } @override Iterable get allTables => allSchemaEntities.whereType(); @override List get allSchemaEntities => [todos, categories]; } class CategoriesWithCountResult { final int id; final String desc; final int amount; CategoriesWithCountResult({ @required this.id, @required this.desc, @required this.amount, }); }