// GENERATED CODE - DO NOT MODIFY BY HAND part of 'todos.dart'; // ************************************************************************** // MoorGenerator // ************************************************************************** // ignore_for_file: unnecessary_brace_in_string_interps class TodoEntry extends DataClass implements Insertable { final int id; final String title; final String content; final DateTime targetDate; final int category; TodoEntry( {@required this.id, this.title, @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']), title: stringType.mapFromDatabaseResponse(data['${effectivePrefix}title']), 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']), title: serializer.fromJson(json['title']), content: serializer.fromJson(json['content']), targetDate: serializer.fromJson(json['target_date']), category: serializer.fromJson(json['category']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'title': serializer.toJson(title), 'content': serializer.toJson(content), 'target_date': serializer.toJson(targetDate), 'category': serializer.toJson(category), }; } @override T createCompanion>(bool nullToAbsent) { return TodosTableCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), title: title == null && nullToAbsent ? const Value.absent() : Value(title), 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), ) as T; } TodoEntry copyWith( {int id, String title, String content, DateTime targetDate, int category}) => TodoEntry( id: id ?? this.id, title: title ?? this.title, content: content ?? this.content, targetDate: targetDate ?? this.targetDate, category: category ?? this.category, ); @override String toString() { return (StringBuffer('TodoEntry(') ..write('id: $id, ') ..write('title: $title, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') ..write('category: $category') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc( id.hashCode, $mrjc( title.hashCode, $mrjc(content.hashCode, $mrjc(targetDate.hashCode, category.hashCode))))); @override bool operator ==(other) => identical(this, other) || (other is TodoEntry && other.id == id && other.title == title && other.content == content && other.targetDate == targetDate && other.category == category); } class TodosTableCompanion extends UpdateCompanion { final Value id; final Value title; final Value content; final Value targetDate; final Value category; const TodosTableCompanion({ this.id = const Value.absent(), this.title = const Value.absent(), this.content = const Value.absent(), this.targetDate = const Value.absent(), this.category = const Value.absent(), }); } class $TodosTableTable extends TodosTable with TableInfo<$TodosTableTable, TodoEntry> { final GeneratedDatabase _db; final String _alias; $TodosTableTable(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); } final VerificationMeta _titleMeta = const VerificationMeta('title'); GeneratedTextColumn _title; @override GeneratedTextColumn get title => _title ??= _constructTitle(); GeneratedTextColumn _constructTitle() { return GeneratedTextColumn('title', $tableName, true, minTextLength: 4, maxTextLength: 16); } 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, ); } @override List get $columns => [id, title, content, targetDate, category]; @override $TodosTableTable get asDslTable => this; @override String get $tableName => _alias ?? 'todos'; @override final String actualTableName = 'todos'; @override VerificationContext validateIntegrity(TodosTableCompanion 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.title.present) { context.handle( _titleMeta, title.isAcceptableValue(d.title.value, _titleMeta)); } else if (title.isRequired && isInserting) { context.missing(_titleMeta); } 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(TodosTableCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.title.present) { map['title'] = Variable(d.title.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 $TodosTableTable createAlias(String alias) { return $TodosTableTable(_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 T createCompanion>(bool nullToAbsent) { return CategoriesCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), description: description == null && nullToAbsent ? const Value.absent() : Value(description), ) as T; } 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 == id && other.description == description); } class CategoriesCompanion extends UpdateCompanion { final Value id; final Value description; const CategoriesCompanion({ this.id = const Value.absent(), this.description = const Value.absent(), }); } 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); } final VerificationMeta _descriptionMeta = const VerificationMeta('description'); GeneratedTextColumn _description; @override GeneratedTextColumn get description => _description ??= _constructDescription(); GeneratedTextColumn _constructDescription() { return GeneratedTextColumn('desc', $tableName, false, $customConstraints: 'NOT NULL UNIQUE'); } @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); } } class User extends DataClass implements Insertable { final int id; final String name; final bool isAwesome; final Uint8List profilePicture; final DateTime creationTime; User( {@required this.id, @required this.name, @required this.isAwesome, @required this.profilePicture, @required this.creationTime}); factory User.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); final boolType = db.typeSystem.forDartType(); final uint8ListType = db.typeSystem.forDartType(); final dateTimeType = db.typeSystem.forDartType(); return User( id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), name: stringType.mapFromDatabaseResponse(data['${effectivePrefix}name']), isAwesome: boolType .mapFromDatabaseResponse(data['${effectivePrefix}is_awesome']), profilePicture: uint8ListType .mapFromDatabaseResponse(data['${effectivePrefix}profile_picture']), creationTime: dateTimeType .mapFromDatabaseResponse(data['${effectivePrefix}creation_time']), ); } factory User.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return User( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), isAwesome: serializer.fromJson(json['isAwesome']), profilePicture: serializer.fromJson(json['profilePicture']), creationTime: serializer.fromJson(json['creationTime']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), 'isAwesome': serializer.toJson(isAwesome), 'profilePicture': serializer.toJson(profilePicture), 'creationTime': serializer.toJson(creationTime), }; } @override T createCompanion>(bool nullToAbsent) { return UsersCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), name: name == null && nullToAbsent ? const Value.absent() : Value(name), isAwesome: isAwesome == null && nullToAbsent ? const Value.absent() : Value(isAwesome), profilePicture: profilePicture == null && nullToAbsent ? const Value.absent() : Value(profilePicture), creationTime: creationTime == null && nullToAbsent ? const Value.absent() : Value(creationTime), ) as T; } User copyWith( {int id, String name, bool isAwesome, Uint8List profilePicture, DateTime creationTime}) => User( id: id ?? this.id, name: name ?? this.name, isAwesome: isAwesome ?? this.isAwesome, profilePicture: profilePicture ?? this.profilePicture, creationTime: creationTime ?? this.creationTime, ); @override String toString() { return (StringBuffer('User(') ..write('id: $id, ') ..write('name: $name, ') ..write('isAwesome: $isAwesome, ') ..write('profilePicture: $profilePicture, ') ..write('creationTime: $creationTime') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc( id.hashCode, $mrjc( name.hashCode, $mrjc(isAwesome.hashCode, $mrjc(profilePicture.hashCode, creationTime.hashCode))))); @override bool operator ==(other) => identical(this, other) || (other is User && other.id == id && other.name == name && other.isAwesome == isAwesome && other.profilePicture == profilePicture && other.creationTime == creationTime); } class UsersCompanion extends UpdateCompanion { final Value id; final Value name; final Value isAwesome; final Value profilePicture; final Value creationTime; const UsersCompanion({ this.id = const Value.absent(), this.name = const Value.absent(), this.isAwesome = const Value.absent(), this.profilePicture = const Value.absent(), this.creationTime = const Value.absent(), }); } class $UsersTable extends Users with TableInfo<$UsersTable, User> { final GeneratedDatabase _db; final String _alias; $UsersTable(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); } final VerificationMeta _nameMeta = const VerificationMeta('name'); GeneratedTextColumn _name; @override GeneratedTextColumn get name => _name ??= _constructName(); GeneratedTextColumn _constructName() { return GeneratedTextColumn('name', $tableName, false, minTextLength: 6, maxTextLength: 32); } final VerificationMeta _isAwesomeMeta = const VerificationMeta('isAwesome'); GeneratedBoolColumn _isAwesome; @override GeneratedBoolColumn get isAwesome => _isAwesome ??= _constructIsAwesome(); GeneratedBoolColumn _constructIsAwesome() { return GeneratedBoolColumn('is_awesome', $tableName, false, defaultValue: const Constant(true)); } final VerificationMeta _profilePictureMeta = const VerificationMeta('profilePicture'); GeneratedBlobColumn _profilePicture; @override GeneratedBlobColumn get profilePicture => _profilePicture ??= _constructProfilePicture(); GeneratedBlobColumn _constructProfilePicture() { return GeneratedBlobColumn( 'profile_picture', $tableName, false, ); } final VerificationMeta _creationTimeMeta = const VerificationMeta('creationTime'); GeneratedDateTimeColumn _creationTime; @override GeneratedDateTimeColumn get creationTime => _creationTime ??= _constructCreationTime(); GeneratedDateTimeColumn _constructCreationTime() { return GeneratedDateTimeColumn('creation_time', $tableName, false, defaultValue: currentDateAndTime); } @override List get $columns => [id, name, isAwesome, profilePicture, creationTime]; @override $UsersTable get asDslTable => this; @override String get $tableName => _alias ?? 'users'; @override final String actualTableName = 'users'; @override VerificationContext validateIntegrity(UsersCompanion 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.name.present) { context.handle( _nameMeta, name.isAcceptableValue(d.name.value, _nameMeta)); } else if (name.isRequired && isInserting) { context.missing(_nameMeta); } if (d.isAwesome.present) { context.handle(_isAwesomeMeta, isAwesome.isAcceptableValue(d.isAwesome.value, _isAwesomeMeta)); } else if (isAwesome.isRequired && isInserting) { context.missing(_isAwesomeMeta); } if (d.profilePicture.present) { context.handle( _profilePictureMeta, profilePicture.isAcceptableValue( d.profilePicture.value, _profilePictureMeta)); } else if (profilePicture.isRequired && isInserting) { context.missing(_profilePictureMeta); } if (d.creationTime.present) { context.handle( _creationTimeMeta, creationTime.isAcceptableValue( d.creationTime.value, _creationTimeMeta)); } else if (creationTime.isRequired && isInserting) { context.missing(_creationTimeMeta); } return context; } @override Set get $primaryKey => {id}; @override User map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return User.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(UsersCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.name.present) { map['name'] = Variable(d.name.value); } if (d.isAwesome.present) { map['is_awesome'] = Variable(d.isAwesome.value); } if (d.profilePicture.present) { map['profile_picture'] = Variable(d.profilePicture.value); } if (d.creationTime.present) { map['creation_time'] = Variable(d.creationTime.value); } return map; } @override $UsersTable createAlias(String alias) { return $UsersTable(_db, alias); } } class SharedTodo extends DataClass implements Insertable { final int todo; final int user; SharedTodo({@required this.todo, @required this.user}); factory SharedTodo.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); return SharedTodo( todo: intType.mapFromDatabaseResponse(data['${effectivePrefix}todo']), user: intType.mapFromDatabaseResponse(data['${effectivePrefix}user']), ); } factory SharedTodo.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return SharedTodo( todo: serializer.fromJson(json['todo']), user: serializer.fromJson(json['user']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'todo': serializer.toJson(todo), 'user': serializer.toJson(user), }; } @override T createCompanion>(bool nullToAbsent) { return SharedTodosCompanion( todo: todo == null && nullToAbsent ? const Value.absent() : Value(todo), user: user == null && nullToAbsent ? const Value.absent() : Value(user), ) as T; } SharedTodo copyWith({int todo, int user}) => SharedTodo( todo: todo ?? this.todo, user: user ?? this.user, ); @override String toString() { return (StringBuffer('SharedTodo(') ..write('todo: $todo, ') ..write('user: $user') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc(todo.hashCode, user.hashCode)); @override bool operator ==(other) => identical(this, other) || (other is SharedTodo && other.todo == todo && other.user == user); } class SharedTodosCompanion extends UpdateCompanion { final Value todo; final Value user; const SharedTodosCompanion({ this.todo = const Value.absent(), this.user = const Value.absent(), }); } class $SharedTodosTable extends SharedTodos with TableInfo<$SharedTodosTable, SharedTodo> { final GeneratedDatabase _db; final String _alias; $SharedTodosTable(this._db, [this._alias]); final VerificationMeta _todoMeta = const VerificationMeta('todo'); GeneratedIntColumn _todo; @override GeneratedIntColumn get todo => _todo ??= _constructTodo(); GeneratedIntColumn _constructTodo() { return GeneratedIntColumn( 'todo', $tableName, false, ); } final VerificationMeta _userMeta = const VerificationMeta('user'); GeneratedIntColumn _user; @override GeneratedIntColumn get user => _user ??= _constructUser(); GeneratedIntColumn _constructUser() { return GeneratedIntColumn( 'user', $tableName, false, ); } @override List get $columns => [todo, user]; @override $SharedTodosTable get asDslTable => this; @override String get $tableName => _alias ?? 'shared_todos'; @override final String actualTableName = 'shared_todos'; @override VerificationContext validateIntegrity(SharedTodosCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.todo.present) { context.handle( _todoMeta, todo.isAcceptableValue(d.todo.value, _todoMeta)); } else if (todo.isRequired && isInserting) { context.missing(_todoMeta); } if (d.user.present) { context.handle( _userMeta, user.isAcceptableValue(d.user.value, _userMeta)); } else if (user.isRequired && isInserting) { context.missing(_userMeta); } return context; } @override Set get $primaryKey => {todo, user}; @override SharedTodo map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return SharedTodo.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(SharedTodosCompanion d) { final map = {}; if (d.todo.present) { map['todo'] = Variable(d.todo.value); } if (d.user.present) { map['user'] = Variable(d.user.value); } return map; } @override $SharedTodosTable createAlias(String alias) { return $SharedTodosTable(_db, alias); } } class TableWithoutPKData extends DataClass implements Insertable { final int notReallyAnId; final double someFloat; final MyCustomObject custom; TableWithoutPKData( {@required this.notReallyAnId, @required this.someFloat, @required this.custom}); factory TableWithoutPKData.fromData( Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final doubleType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); return TableWithoutPKData( notReallyAnId: intType .mapFromDatabaseResponse(data['${effectivePrefix}not_really_an_id']), someFloat: doubleType .mapFromDatabaseResponse(data['${effectivePrefix}some_float']), custom: $TableWithoutPKTable.$converter0.mapToDart( stringType.mapFromDatabaseResponse(data['${effectivePrefix}custom'])), ); } factory TableWithoutPKData.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return TableWithoutPKData( notReallyAnId: serializer.fromJson(json['notReallyAnId']), someFloat: serializer.fromJson(json['someFloat']), custom: serializer.fromJson(json['custom']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'notReallyAnId': serializer.toJson(notReallyAnId), 'someFloat': serializer.toJson(someFloat), 'custom': serializer.toJson(custom), }; } @override T createCompanion>( bool nullToAbsent) { return TableWithoutPKCompanion( notReallyAnId: notReallyAnId == null && nullToAbsent ? const Value.absent() : Value(notReallyAnId), someFloat: someFloat == null && nullToAbsent ? const Value.absent() : Value(someFloat), custom: custom == null && nullToAbsent ? const Value.absent() : Value(custom), ) as T; } TableWithoutPKData copyWith( {int notReallyAnId, double someFloat, MyCustomObject custom}) => TableWithoutPKData( notReallyAnId: notReallyAnId ?? this.notReallyAnId, someFloat: someFloat ?? this.someFloat, custom: custom ?? this.custom, ); @override String toString() { return (StringBuffer('TableWithoutPKData(') ..write('notReallyAnId: $notReallyAnId, ') ..write('someFloat: $someFloat, ') ..write('custom: $custom') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc( notReallyAnId.hashCode, $mrjc(someFloat.hashCode, custom.hashCode))); @override bool operator ==(other) => identical(this, other) || (other is TableWithoutPKData && other.notReallyAnId == notReallyAnId && other.someFloat == someFloat && other.custom == custom); } class TableWithoutPKCompanion extends UpdateCompanion { final Value notReallyAnId; final Value someFloat; final Value custom; const TableWithoutPKCompanion({ this.notReallyAnId = const Value.absent(), this.someFloat = const Value.absent(), this.custom = const Value.absent(), }); } class $TableWithoutPKTable extends TableWithoutPK with TableInfo<$TableWithoutPKTable, TableWithoutPKData> { final GeneratedDatabase _db; final String _alias; $TableWithoutPKTable(this._db, [this._alias]); final VerificationMeta _notReallyAnIdMeta = const VerificationMeta('notReallyAnId'); GeneratedIntColumn _notReallyAnId; @override GeneratedIntColumn get notReallyAnId => _notReallyAnId ??= _constructNotReallyAnId(); GeneratedIntColumn _constructNotReallyAnId() { return GeneratedIntColumn( 'not_really_an_id', $tableName, false, ); } final VerificationMeta _someFloatMeta = const VerificationMeta('someFloat'); GeneratedRealColumn _someFloat; @override GeneratedRealColumn get someFloat => _someFloat ??= _constructSomeFloat(); GeneratedRealColumn _constructSomeFloat() { return GeneratedRealColumn( 'some_float', $tableName, false, ); } final VerificationMeta _customMeta = const VerificationMeta('custom'); GeneratedTextColumn _custom; @override GeneratedTextColumn get custom => _custom ??= _constructCustom(); GeneratedTextColumn _constructCustom() { return GeneratedTextColumn( 'custom', $tableName, false, ); } @override List get $columns => [notReallyAnId, someFloat, custom]; @override $TableWithoutPKTable get asDslTable => this; @override String get $tableName => _alias ?? 'table_without_p_k'; @override final String actualTableName = 'table_without_p_k'; @override VerificationContext validateIntegrity(TableWithoutPKCompanion d, {bool isInserting = false}) { final context = VerificationContext(); if (d.notReallyAnId.present) { context.handle( _notReallyAnIdMeta, notReallyAnId.isAcceptableValue( d.notReallyAnId.value, _notReallyAnIdMeta)); } else if (notReallyAnId.isRequired && isInserting) { context.missing(_notReallyAnIdMeta); } if (d.someFloat.present) { context.handle(_someFloatMeta, someFloat.isAcceptableValue(d.someFloat.value, _someFloatMeta)); } else if (someFloat.isRequired && isInserting) { context.missing(_someFloatMeta); } context.handle(_customMeta, const VerificationResult.success()); return context; } @override Set get $primaryKey => {}; @override TableWithoutPKData map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return TableWithoutPKData.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(TableWithoutPKCompanion d) { final map = {}; if (d.notReallyAnId.present) { map['not_really_an_id'] = Variable(d.notReallyAnId.value); } if (d.someFloat.present) { map['some_float'] = Variable(d.someFloat.value); } if (d.custom.present) { final converter = $TableWithoutPKTable.$converter0; map['custom'] = Variable(converter.mapToSql(d.custom.value)); } return map; } @override $TableWithoutPKTable createAlias(String alias) { return $TableWithoutPKTable(_db, alias); } static CustomConverter $converter0 = const CustomConverter(); } class PureDefault extends DataClass implements Insertable { final int id; final String txt; PureDefault({@required this.id, this.txt}); factory PureDefault.fromData(Map data, GeneratedDatabase db, {String prefix}) { final effectivePrefix = prefix ?? ''; final intType = db.typeSystem.forDartType(); final stringType = db.typeSystem.forDartType(); return PureDefault( id: intType.mapFromDatabaseResponse(data['${effectivePrefix}id']), txt: stringType.mapFromDatabaseResponse(data['${effectivePrefix}txt']), ); } factory PureDefault.fromJson(Map json, {ValueSerializer serializer = const ValueSerializer.defaults()}) { return PureDefault( id: serializer.fromJson(json['id']), txt: serializer.fromJson(json['txt']), ); } @override Map toJson( {ValueSerializer serializer = const ValueSerializer.defaults()}) { return { 'id': serializer.toJson(id), 'txt': serializer.toJson(txt), }; } @override T createCompanion>(bool nullToAbsent) { return PureDefaultsCompanion( id: id == null && nullToAbsent ? const Value.absent() : Value(id), txt: txt == null && nullToAbsent ? const Value.absent() : Value(txt), ) as T; } PureDefault copyWith({int id, String txt}) => PureDefault( id: id ?? this.id, txt: txt ?? this.txt, ); @override String toString() { return (StringBuffer('PureDefault(') ..write('id: $id, ') ..write('txt: $txt') ..write(')')) .toString(); } @override int get hashCode => $mrjf($mrjc(id.hashCode, txt.hashCode)); @override bool operator ==(other) => identical(this, other) || (other is PureDefault && other.id == id && other.txt == txt); } class PureDefaultsCompanion extends UpdateCompanion { final Value id; final Value txt; const PureDefaultsCompanion({ this.id = const Value.absent(), this.txt = const Value.absent(), }); } class $PureDefaultsTable extends PureDefaults with TableInfo<$PureDefaultsTable, PureDefault> { final GeneratedDatabase _db; final String _alias; $PureDefaultsTable(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); } final VerificationMeta _txtMeta = const VerificationMeta('txt'); GeneratedTextColumn _txt; @override GeneratedTextColumn get txt => _txt ??= _constructTxt(); GeneratedTextColumn _constructTxt() { return GeneratedTextColumn( 'txt', $tableName, true, ); } @override List get $columns => [id, txt]; @override $PureDefaultsTable get asDslTable => this; @override String get $tableName => _alias ?? 'pure_defaults'; @override final String actualTableName = 'pure_defaults'; @override VerificationContext validateIntegrity(PureDefaultsCompanion 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.txt.present) { context.handle(_txtMeta, txt.isAcceptableValue(d.txt.value, _txtMeta)); } else if (txt.isRequired && isInserting) { context.missing(_txtMeta); } return context; } @override Set get $primaryKey => {id}; @override PureDefault map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; return PureDefault.fromData(data, _db, prefix: effectivePrefix); } @override Map entityToSql(PureDefaultsCompanion d) { final map = {}; if (d.id.present) { map['id'] = Variable(d.id.value); } if (d.txt.present) { map['txt'] = Variable(d.txt.value); } return map; } @override $PureDefaultsTable createAlias(String alias) { return $PureDefaultsTable(_db, alias); } } class AllTodosWithCategoryResult { final int id; final String title; final String content; final DateTime targetDate; final int category; final int catId; final String catDesc; AllTodosWithCategoryResult({ this.id, this.title, this.content, this.targetDate, this.category, this.catId, this.catDesc, }); } abstract class _$TodoDb extends GeneratedDatabase { _$TodoDb(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e); $TodosTableTable _todosTable; $TodosTableTable get todosTable => _todosTable ??= $TodosTableTable(this); $CategoriesTable _categories; $CategoriesTable get categories => _categories ??= $CategoriesTable(this); $UsersTable _users; $UsersTable get users => _users ??= $UsersTable(this); $SharedTodosTable _sharedTodos; $SharedTodosTable get sharedTodos => _sharedTodos ??= $SharedTodosTable(this); $TableWithoutPKTable _tableWithoutPK; $TableWithoutPKTable get tableWithoutPK => _tableWithoutPK ??= $TableWithoutPKTable(this); $PureDefaultsTable _pureDefaults; $PureDefaultsTable get pureDefaults => _pureDefaults ??= $PureDefaultsTable(this); SomeDao _someDao; SomeDao get someDao => _someDao ??= SomeDao(this as TodoDb); AllTodosWithCategoryResult _rowToAllTodosWithCategoryResult(QueryRow row) { return AllTodosWithCategoryResult( id: row.readInt('id'), title: row.readString('title'), content: row.readString('content'), targetDate: row.readDateTime('target_date'), category: row.readInt('category'), catId: row.readInt('catId'), catDesc: row.readString('catDesc'), ); } Future> allTodosWithCategory( {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect( 'SELECT t.*, c.id as catId, c."desc" as catDesc FROM todos t INNER JOIN categories c ON c.id = t.category', variables: []).then((rows) => rows.map(_rowToAllTodosWithCategoryResult).toList()); } Stream> watchAllTodosWithCategory() { return customSelectStream( 'SELECT t.*, c.id as catId, c."desc" as catDesc FROM todos t INNER JOIN categories c ON c.id = t.category', variables: [], readsFrom: { categories, todosTable }).map((rows) => rows.map(_rowToAllTodosWithCategoryResult).toList()); } Future deleteTodoById( int var1, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customUpdate( 'DELETE FROM todos WHERE id = ?', variables: [ Variable.withInt(var1), ], updates: {todosTable}, ); } TodoEntry _rowToTodoEntry(QueryRow row) { return TodoEntry( id: row.readInt('id'), title: row.readString('title'), content: row.readString('content'), targetDate: row.readDateTime('target_date'), category: row.readInt('category'), ); } Future> withIn( String var1, String var2, List var3, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { final expandedvar3 = List.filled(var3.length, '?').join(','); return (operateOn ?? this).customSelect( 'SELECT * FROM todos WHERE title = ?2 OR id IN ($expandedvar3) OR title = ?1', variables: [ Variable.withString(var1), Variable.withString(var2), for (var $ in var3) Variable.withInt($), ]).then((rows) => rows.map(_rowToTodoEntry).toList()); } Stream> watchWithIn( String var1, String var2, List var3) { final expandedvar3 = List.filled(var3.length, '?').join(','); return customSelectStream( 'SELECT * FROM todos WHERE title = ?2 OR id IN ($expandedvar3) OR title = ?1', variables: [ Variable.withString(var1), Variable.withString(var2), for (var $ in var3) Variable.withInt($), ], readsFrom: { todosTable }).map((rows) => rows.map(_rowToTodoEntry).toList()); } Future> search( int id, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect( 'SELECT * FROM todos WHERE CASE WHEN -1 = :id THEN 1 ELSE id = :id END', variables: [ Variable.withInt(id), ]).then((rows) => rows.map(_rowToTodoEntry).toList()); } Stream> watchSearch(int id) { return customSelectStream( 'SELECT * FROM todos WHERE CASE WHEN -1 = :id THEN 1 ELSE id = :id END', variables: [ Variable.withInt(id), ], readsFrom: { todosTable }).map((rows) => rows.map(_rowToTodoEntry).toList()); } @override List get allTables => [ todosTable, categories, users, sharedTodos, tableWithoutPK, pureDefaults ]; } // ************************************************************************** // DaoGenerator // ************************************************************************** mixin _$SomeDaoMixin on DatabaseAccessor { $UsersTable get users => db.users; $SharedTodosTable get sharedTodos => db.sharedTodos; $TodosTableTable get todosTable => db.todosTable; TodoEntry _rowToTodoEntry(QueryRow row) { return TodoEntry( id: row.readInt('id'), title: row.readString('title'), content: row.readString('content'), targetDate: row.readDateTime('target_date'), category: row.readInt('category'), ); } Future> todosForUser( int user, {@Deprecated('No longer needed with Moor 1.6 - see the changelog for details') QueryEngine operateOn}) { return (operateOn ?? this).customSelect( 'SELECT t.* FROM todos t INNER JOIN shared_todos st ON st.todo = t.id INNER JOIN users u ON u.id = st.user WHERE u.id = :user', variables: [ Variable.withInt(user), ]).then((rows) => rows.map(_rowToTodoEntry).toList()); } Stream> watchTodosForUser(int user) { return customSelectStream( 'SELECT t.* FROM todos t INNER JOIN shared_todos st ON st.todo = t.id INNER JOIN users u ON u.id = st.user WHERE u.id = :user', variables: [ Variable.withInt(user), ], readsFrom: { todosTable, sharedTodos, users }).map((rows) => rows.map(_rowToTodoEntry).toList()); } }