// GENERATED CODE - DO NOT MODIFY BY HAND part of 'database.dart'; // ignore_for_file: type=lint class $CategoriesTable extends Categories with TableInfo<$CategoriesTable, Category> { @override final GeneratedDatabase attachedDatabase; final String? _alias; $CategoriesTable(this.attachedDatabase, [this._alias]); static const VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( 'id', aliasedName, false, hasAutoIncrement: true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); static const VerificationMeta _nameMeta = const VerificationMeta('name'); @override late final GeneratedColumn name = GeneratedColumn( 'name', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true); static const VerificationMeta _colorMeta = const VerificationMeta('color'); @override late final GeneratedColumnWithTypeConverter color = GeneratedColumn('color', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true) .withConverter($CategoriesTable.$convertercolor); @override List get $columns => [id, name, color]; @override String get aliasedName => _alias ?? actualTableName; @override String get actualTableName => $name; static const String $name = '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('name')) { context.handle( _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); } else if (isInserting) { context.missing(_nameMeta); } context.handle(_colorMeta, const VerificationResult.success()); return context; } @override Set get $primaryKey => {id}; @override Category map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return Category( id: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}id'])!, name: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}name'])!, color: $CategoriesTable.$convertercolor.fromSql(attachedDatabase .typeMapping .read(DriftSqlType.int, data['${effectivePrefix}color'])!), ); } @override $CategoriesTable createAlias(String alias) { return $CategoriesTable(attachedDatabase, alias); } static TypeConverter $convertercolor = const ColorConverter(); } class Category extends DataClass implements Insertable { final int id; final String name; final Color color; const Category({required this.id, required this.name, required this.color}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); map['name'] = Variable(name); { final converter = $CategoriesTable.$convertercolor; map['color'] = Variable(converter.toSql(color)); } return map; } CategoriesCompanion toCompanion(bool nullToAbsent) { return CategoriesCompanion( id: Value(id), name: Value(name), color: Value(color), ); } factory Category.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return Category( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), color: serializer.fromJson(json['color']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), 'color': serializer.toJson(color), }; } Category copyWith({int? id, String? name, Color? color}) => Category( id: id ?? this.id, name: name ?? this.name, color: color ?? this.color, ); @override String toString() { return (StringBuffer('Category(') ..write('id: $id, ') ..write('name: $name, ') ..write('color: $color') ..write(')')) .toString(); } @override int get hashCode => Object.hash(id, name, color); @override bool operator ==(Object other) => identical(this, other) || (other is Category && other.id == this.id && other.name == this.name && other.color == this.color); } class CategoriesCompanion extends UpdateCompanion { final Value id; final Value name; final Value color; const CategoriesCompanion({ this.id = const Value.absent(), this.name = const Value.absent(), this.color = const Value.absent(), }); CategoriesCompanion.insert({ this.id = const Value.absent(), required String name, required Color color, }) : name = Value(name), color = Value(color); static Insertable custom({ Expression? id, Expression? name, Expression? color, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (name != null) 'name': name, if (color != null) 'color': color, }); } CategoriesCompanion copyWith( {Value? id, Value? name, Value? color}) { return CategoriesCompanion( id: id ?? this.id, name: name ?? this.name, color: color ?? this.color, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (id.present) { map['id'] = Variable(id.value); } if (name.present) { map['name'] = Variable(name.value); } if (color.present) { final converter = $CategoriesTable.$convertercolor; map['color'] = Variable(converter.toSql(color.value)); } return map; } @override String toString() { return (StringBuffer('CategoriesCompanion(') ..write('id: $id, ') ..write('name: $name, ') ..write('color: $color') ..write(')')) .toString(); } } class $TodoEntriesTable extends TodoEntries with TableInfo<$TodoEntriesTable, TodoEntry> { @override final GeneratedDatabase attachedDatabase; final String? _alias; $TodoEntriesTable(this.attachedDatabase, [this._alias]); static const VerificationMeta _idMeta = const VerificationMeta('id'); @override late final GeneratedColumn id = GeneratedColumn( 'id', aliasedName, false, hasAutoIncrement: true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); @override late final GeneratedColumn description = GeneratedColumn( 'description', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true); static const VerificationMeta _categoryMeta = const VerificationMeta('category'); @override late final GeneratedColumn category = GeneratedColumn( 'category', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways('REFERENCES categories (id)')); static const VerificationMeta _dueDateMeta = const VerificationMeta('dueDate'); @override late final GeneratedColumn dueDate = GeneratedColumn( 'due_date', aliasedName, true, type: DriftSqlType.dateTime, requiredDuringInsert: false); @override List get $columns => [id, description, category, dueDate]; @override String get aliasedName => _alias ?? actualTableName; @override String get actualTableName => $name; static const String $name = 'todo_entries'; @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('description')) { context.handle( _descriptionMeta, description.isAcceptableOrUnknown( data['description']!, _descriptionMeta)); } else if (isInserting) { context.missing(_descriptionMeta); } if (data.containsKey('category')) { context.handle(_categoryMeta, category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); } if (data.containsKey('due_date')) { context.handle(_dueDateMeta, dueDate.isAcceptableOrUnknown(data['due_date']!, _dueDateMeta)); } return context; } @override Set get $primaryKey => {id}; @override TodoEntry map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return TodoEntry( id: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}id'])!, description: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}description'])!, category: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}category']), dueDate: attachedDatabase.typeMapping .read(DriftSqlType.dateTime, data['${effectivePrefix}due_date']), ); } @override $TodoEntriesTable createAlias(String alias) { return $TodoEntriesTable(attachedDatabase, alias); } } class TodoEntry extends DataClass implements Insertable { final int id; final String description; final int? category; final DateTime? dueDate; const TodoEntry( {required this.id, required this.description, this.category, this.dueDate}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['id'] = Variable(id); map['description'] = Variable(description); if (!nullToAbsent || category != null) { map['category'] = Variable(category); } if (!nullToAbsent || dueDate != null) { map['due_date'] = Variable(dueDate); } return map; } TodoEntriesCompanion toCompanion(bool nullToAbsent) { return TodoEntriesCompanion( id: Value(id), description: Value(description), category: category == null && nullToAbsent ? const Value.absent() : Value(category), dueDate: dueDate == null && nullToAbsent ? const Value.absent() : Value(dueDate), ); } factory TodoEntry.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return TodoEntry( id: serializer.fromJson(json['id']), description: serializer.fromJson(json['description']), category: serializer.fromJson(json['category']), dueDate: serializer.fromJson(json['dueDate']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'description': serializer.toJson(description), 'category': serializer.toJson(category), 'dueDate': serializer.toJson(dueDate), }; } TodoEntry copyWith( {int? id, String? description, Value category = const Value.absent(), Value dueDate = const Value.absent()}) => TodoEntry( id: id ?? this.id, description: description ?? this.description, category: category.present ? category.value : this.category, dueDate: dueDate.present ? dueDate.value : this.dueDate, ); @override String toString() { return (StringBuffer('TodoEntry(') ..write('id: $id, ') ..write('description: $description, ') ..write('category: $category, ') ..write('dueDate: $dueDate') ..write(')')) .toString(); } @override int get hashCode => Object.hash(id, description, category, dueDate); @override bool operator ==(Object other) => identical(this, other) || (other is TodoEntry && other.id == this.id && other.description == this.description && other.category == this.category && other.dueDate == this.dueDate); } class TodoEntriesCompanion extends UpdateCompanion { final Value id; final Value description; final Value category; final Value dueDate; const TodoEntriesCompanion({ this.id = const Value.absent(), this.description = const Value.absent(), this.category = const Value.absent(), this.dueDate = const Value.absent(), }); TodoEntriesCompanion.insert({ this.id = const Value.absent(), required String description, this.category = const Value.absent(), this.dueDate = const Value.absent(), }) : description = Value(description); static Insertable custom({ Expression? id, Expression? description, Expression? category, Expression? dueDate, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (description != null) 'description': description, if (category != null) 'category': category, if (dueDate != null) 'due_date': dueDate, }); } TodoEntriesCompanion copyWith( {Value? id, Value? description, Value? category, Value? dueDate}) { return TodoEntriesCompanion( id: id ?? this.id, description: description ?? this.description, category: category ?? this.category, dueDate: dueDate ?? this.dueDate, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (id.present) { map['id'] = Variable(id.value); } if (description.present) { map['description'] = Variable(description.value); } if (category.present) { map['category'] = Variable(category.value); } if (dueDate.present) { map['due_date'] = Variable(dueDate.value); } return map; } @override String toString() { return (StringBuffer('TodoEntriesCompanion(') ..write('id: $id, ') ..write('description: $description, ') ..write('category: $category, ') ..write('dueDate: $dueDate') ..write(')')) .toString(); } } class TextEntries extends Table with TableInfo, VirtualTableInfo { @override final GeneratedDatabase attachedDatabase; final String? _alias; TextEntries(this.attachedDatabase, [this._alias]); static const VerificationMeta _descriptionMeta = const VerificationMeta('description'); late final GeneratedColumn description = GeneratedColumn( 'description', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: ''); @override List get $columns => [description]; @override String get aliasedName => _alias ?? actualTableName; @override String get actualTableName => $name; static const String $name = 'text_entries'; @override VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { final context = VerificationContext(); final data = instance.toColumns(true); if (data.containsKey('description')) { context.handle( _descriptionMeta, description.isAcceptableOrUnknown( data['description']!, _descriptionMeta)); } else if (isInserting) { context.missing(_descriptionMeta); } return context; } @override Set get $primaryKey => const {}; @override TextEntry map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return TextEntry( description: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}description'])!, ); } @override TextEntries createAlias(String alias) { return TextEntries(attachedDatabase, alias); } @override bool get dontWriteConstraints => true; @override String get moduleAndArgs => 'fts5(description, content=todo_entries, content_rowid=id)'; } class TextEntry extends DataClass implements Insertable { final String description; const TextEntry({required this.description}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['description'] = Variable(description); return map; } TextEntriesCompanion toCompanion(bool nullToAbsent) { return TextEntriesCompanion( description: Value(description), ); } factory TextEntry.fromJson(Map json, {ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return TextEntry( description: serializer.fromJson(json['description']), ); } @override Map toJson({ValueSerializer? serializer}) { serializer ??= driftRuntimeOptions.defaultSerializer; return { 'description': serializer.toJson(description), }; } TextEntry copyWith({String? description}) => TextEntry( description: description ?? this.description, ); @override String toString() { return (StringBuffer('TextEntry(') ..write('description: $description') ..write(')')) .toString(); } @override int get hashCode => description.hashCode; @override bool operator ==(Object other) => identical(this, other) || (other is TextEntry && other.description == this.description); } class TextEntriesCompanion extends UpdateCompanion { final Value description; final Value rowid; const TextEntriesCompanion({ this.description = const Value.absent(), this.rowid = const Value.absent(), }); TextEntriesCompanion.insert({ required String description, this.rowid = const Value.absent(), }) : description = Value(description); static Insertable custom({ Expression? description, Expression? rowid, }) { return RawValuesInsertable({ if (description != null) 'description': description, if (rowid != null) 'rowid': rowid, }); } TextEntriesCompanion copyWith( {Value? description, Value? rowid}) { return TextEntriesCompanion( description: description ?? this.description, rowid: rowid ?? this.rowid, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (description.present) { map['description'] = Variable(description.value); } if (rowid.present) { map['rowid'] = Variable(rowid.value); } return map; } @override String toString() { return (StringBuffer('TextEntriesCompanion(') ..write('description: $description, ') ..write('rowid: $rowid') ..write(')')) .toString(); } } abstract class _$AppDatabase extends GeneratedDatabase { _$AppDatabase(QueryExecutor e) : super(e); late final $CategoriesTable categories = $CategoriesTable(this); late final $TodoEntriesTable todoEntries = $TodoEntriesTable(this); late final TextEntries textEntries = TextEntries(this); late final Trigger todosInsert = Trigger( 'CREATE TRIGGER todos_insert AFTER INSERT ON todo_entries BEGIN INSERT INTO text_entries ("rowid", description) VALUES (new.id, new.description);END', 'todos_insert'); late final Trigger todosDelete = Trigger( 'CREATE TRIGGER todos_delete AFTER DELETE ON todo_entries BEGIN INSERT INTO text_entries (text_entries, "rowid", description) VALUES (\'delete\', old.id, old.description);END', 'todos_delete'); late final Trigger todosUpdate = Trigger( 'CREATE TRIGGER todos_update AFTER UPDATE ON todo_entries BEGIN INSERT INTO text_entries (text_entries, "rowid", description) VALUES (\'delete\', new.id, new.description);INSERT INTO text_entries ("rowid", description) VALUES (new.id, new.description);END', 'todos_update'); Selectable _categoriesWithCount() { return customSelect( 'SELECT c.*, (SELECT COUNT(*) FROM todo_entries WHERE category = c.id) AS amount FROM categories AS c UNION ALL SELECT NULL, NULL, NULL, (SELECT COUNT(*) FROM todo_entries WHERE category IS NULL)', variables: [], readsFrom: { todoEntries, categories, }).map((QueryRow row) => CategoriesWithCountResult( id: row.readNullable('id'), name: row.readNullable('name'), color: NullAwareTypeConverter.wrapFromSql( $CategoriesTable.$convertercolor, row.readNullable('color')), amount: row.read('amount'), )); } Selectable _search(String query) { return customSelect( 'SELECT"todos"."id" AS "nested_0.id", "todos"."description" AS "nested_0.description", "todos"."category" AS "nested_0.category", "todos"."due_date" AS "nested_0.due_date","cat"."id" AS "nested_1.id", "cat"."name" AS "nested_1.name", "cat"."color" AS "nested_1.color" FROM text_entries INNER JOIN todo_entries AS todos ON todos.id = text_entries."rowid" LEFT OUTER JOIN categories AS cat ON cat.id = todos.category WHERE text_entries MATCH ?1 ORDER BY rank', variables: [ Variable(query) ], readsFrom: { textEntries, todoEntries, categories, }).asyncMap((QueryRow row) async => SearchResult( todos: await todoEntries.mapFromRow(row, tablePrefix: 'nested_0'), cat: await categories.mapFromRowOrNull(row, tablePrefix: 'nested_1'), )); } @override Iterable> get allTables => allSchemaEntities.whereType>(); @override List get allSchemaEntities => [ categories, todoEntries, textEntries, todosInsert, todosDelete, todosUpdate ]; @override StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules( [ WritePropagation( on: TableUpdateQuery.onTableName('todo_entries', limitUpdateKind: UpdateKind.insert), result: [ TableUpdate('text_entries', kind: UpdateKind.insert), ], ), WritePropagation( on: TableUpdateQuery.onTableName('todo_entries', limitUpdateKind: UpdateKind.delete), result: [ TableUpdate('text_entries', kind: UpdateKind.insert), ], ), WritePropagation( on: TableUpdateQuery.onTableName('todo_entries', limitUpdateKind: UpdateKind.update), result: [ TableUpdate('text_entries', kind: UpdateKind.insert), ], ), ], ); } class CategoriesWithCountResult { final int? id; final String? name; final Color? color; final int amount; CategoriesWithCountResult({ this.id, this.name, this.color, required this.amount, }); } class SearchResult { final TodoEntry todos; final Category? cat; SearchResult({ required this.todos, this.cat, }); }