From e3b6c56f08a7a898d896ea412b86cd11d2b237e2 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 19 Oct 2022 23:35:54 +0200 Subject: [PATCH] Fix syntax error in generated code for queries --- drift/example/main.g.dart | 6 + drift/test/generated/custom_tables.g.dart | 5 + drift/test/generated/todos.g.dart | 2312 ++++++++++++----- .../src/analysis/resolver/file_analysis.dart | 21 +- drift_dev/lib/src/analysis/results/index.dart | 8 + .../lib/src/analysis/results/trigger.dart | 7 + drift_dev/lib/src/writer/database_writer.dart | 30 +- .../lib/src/writer/queries/query_writer.dart | 3 +- drift_dev/lib/src/writer/writer.dart | 4 + 9 files changed, 1759 insertions(+), 637 deletions(-) diff --git a/drift/example/main.g.dart b/drift/example/main.g.dart index e4e05587..1581f5a6 100644 --- a/drift/example/main.g.dart +++ b/drift/example/main.g.dart @@ -686,4 +686,10 @@ abstract class _$Database extends GeneratedDatabase { $TodoCategoryItemCountView(this); late final $TodoItemWithCategoryNameViewView customViewName = $TodoItemWithCategoryNameViewView(this); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => + [todoItems, todoCategories, todoCategoryItemCount, customViewName]; } diff --git a/drift/test/generated/custom_tables.g.dart b/drift/test/generated/custom_tables.g.dart index ffce932f..d6e55e45 100644 --- a/drift/test/generated/custom_tables.g.dart +++ b/drift/test/generated/custom_tables.g.dart @@ -14,6 +14,11 @@ abstract class _$CustomTablesDb extends GeneratedDatabase { ); } + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => []; @override DriftDatabaseOptions get options => const DriftDatabaseOptions(storeDateTimeAsText: true); diff --git a/drift/test/generated/todos.g.dart b/drift/test/generated/todos.g.dart index e01a60a6..8233b391 100644 --- a/drift/test/generated/todos.g.dart +++ b/drift/test/generated/todos.g.dart @@ -7,654 +7,1732 @@ part of 'todos.dart'; // DriftElementId(asset:drift/test/generated/todos.dart, categories) // DriftElementId(asset:drift/test/generated/todos.dart, todo_with_category_view) class TodoEntry extends DataClass implements Insertable { -final int id; -final String? title; -final String content; -final DateTime? targetDate; -final int? category; -const TodoEntry({required this.id, this.title, required this.content, this.targetDate, this.category});@override -Map toColumns(bool nullToAbsent) { -final map = {};map['id'] = Variable(id);if (!nullToAbsent || title != null){map['title'] = Variable(title);}map['content'] = Variable(content);if (!nullToAbsent || targetDate != null){map['target_date'] = Variable(targetDate);}if (!nullToAbsent || category != null){map['category'] = Variable(category);}return map; + final int id; + final String? title; + final String content; + final DateTime? targetDate; + final int? category; + const TodoEntry( + {required this.id, + this.title, + required this.content, + this.targetDate, + this.category}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || title != null) { + map['title'] = Variable(title); + } + map['content'] = Variable(content); + if (!nullToAbsent || targetDate != null) { + map['target_date'] = Variable(targetDate); + } + if (!nullToAbsent || category != null) { + map['category'] = Variable(category); + } + return map; + } + + TodosTableCompanion toCompanion(bool nullToAbsent) { + return TodosTableCompanion( + id: Value(id), + title: + title == null && nullToAbsent ? const Value.absent() : Value(title), + content: 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 ??= driftRuntimeOptions.defaultSerializer; + 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']), + ); + } + factory TodoEntry.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + TodoEntry.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'title': serializer.toJson(title), + 'content': serializer.toJson(content), + 'target_date': serializer.toJson(targetDate), + 'category': serializer.toJson(category), + }; + } + + TodoEntry copyWith( + {int? id, + Value title = const Value.absent(), + String? content, + Value targetDate = const Value.absent(), + Value category = const Value.absent()}) => + TodoEntry( + id: id ?? this.id, + title: title.present ? title.value : this.title, + content: content ?? this.content, + targetDate: targetDate.present ? targetDate.value : this.targetDate, + category: category.present ? category.value : 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 => Object.hash(id, title, content, targetDate, category); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is TodoEntry && + other.id == this.id && + other.title == this.title && + other.content == this.content && + other.targetDate == this.targetDate && + other.category == this.category); } -TodosTableCompanion toCompanion(bool nullToAbsent) { -return TodosTableCompanion(id: Value (id),title: title == null && nullToAbsent ? const Value.absent() : Value (title),content: Value (content),targetDate: targetDate == null && nullToAbsent ? const Value.absent() : Value (targetDate),category: category == null && nullToAbsent ? const Value.absent() : Value (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(), + }); + TodosTableCompanion.insert({ + this.id = const Value.absent(), + this.title = 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? title, + Expression? content, + Expression? targetDate, + Expression? category, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (title != null) 'title': title, + if (content != null) 'content': content, + if (targetDate != null) 'target_date': targetDate, + if (category != null) 'category': category, + }); + } + + TodosTableCompanion copyWith( + {Value? id, + Value? title, + Value? content, + Value? targetDate, + Value? category}) { + return TodosTableCompanion( + id: id ?? this.id, + title: title ?? this.title, + 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 (title.present) { + map['title'] = Variable(title.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('TodosTableCompanion(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('content: $content, ') + ..write('targetDate: $targetDate, ') + ..write('category: $category') + ..write(')')) + .toString(); + } } -factory TodoEntry.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -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']),);} -factory TodoEntry.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => TodoEntry.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'id': serializer.toJson(id),'title': serializer.toJson(title),'content': serializer.toJson(content),'target_date': serializer.toJson(targetDate),'category': serializer.toJson(category),};}TodoEntry copyWith({int? id,Value title = const Value.absent(),String? content,Value targetDate = const Value.absent(),Value category = const Value.absent()}) => TodoEntry(id: id ?? this.id,title: title.present ? title.value : this.title,content: content ?? this.content,targetDate: targetDate.present ? targetDate.value : this.targetDate,category: category.present ? category.value : 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 => Object.hash(id, title, content, targetDate, category);@override -bool operator ==(Object other) => identical(this, other) || (other is TodoEntry && other.id == this.id && other.title == this.title && other.content == this.content && other.targetDate == this.targetDate && other.category == this.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(),}); -TodosTableCompanion.insert({this.id = const Value.absent(),this.title = 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? title, -Expression? content, -Expression? targetDate, -Expression? category, -}) { -return RawValuesInsertable({if (id != null)'id': id,if (title != null)'title': title,if (content != null)'content': content,if (targetDate != null)'target_date': targetDate,if (category != null)'category': category,}); -}TodosTableCompanion copyWith({Value? id, Value? title, Value? content, Value? targetDate, Value? category}) { -return TodosTableCompanion(id: id ?? this.id,title: title ?? this.title,content: content ?? this.content,targetDate: targetDate ?? this.targetDate,category: category ?? this.category,); + +class $TodosTableTable extends TodosTable + with TableInfo<$TodosTableTable, TodoEntry> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $TodosTableTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); + final VerificationMeta _titleMeta = const VerificationMeta('title'); + @override + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, true, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 4, maxTextLength: 16), + type: DriftSqlType.string, + requiredDuringInsert: false); + final VerificationMeta _contentMeta = const VerificationMeta('content'); + @override + late final GeneratedColumn content = GeneratedColumn( + 'content', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + final VerificationMeta _targetDateMeta = const VerificationMeta('targetDate'); + @override + late final GeneratedColumn targetDate = GeneratedColumn( + 'target_date', aliasedName, true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultConstraints: 'UNIQUE'); + final VerificationMeta _categoryMeta = const VerificationMeta('category'); + @override + late final GeneratedColumn category = GeneratedColumn( + 'category', aliasedName, true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: 'REFERENCES categories (id)'); + @override + List get $columns => + [id, title, content, targetDate, category]; + @override + String get aliasedName => _alias ?? 'todos'; + @override + String get 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('title')) { + context.handle( + _titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta)); + } + 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 + List> get uniqueKeys => [ + {title, category}, + {title, targetDate}, + ]; + @override + TodoEntry map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return TodoEntry( + id: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + title: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}title']), + content: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}content'])!, + targetDate: attachedDatabase.options.types + .read(DriftSqlType.dateTime, data['${effectivePrefix}target_date']), + category: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}category']), + ); + } + + @override + $TodosTableTable createAlias(String alias) { + return $TodosTableTable(attachedDatabase, alias); + } } -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (id.present) {map['id'] = Variable(id.value);}if (title.present) {map['title'] = Variable(title.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; + +class Category extends DataClass implements Insertable { + final int id; + final String description; + final CategoryPriority priority; + final String descriptionInUpperCase; + const Category( + {required this.id, + required this.description, + required this.priority, + required this.descriptionInUpperCase}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['desc'] = Variable(description); + { + final converter = $CategoriesTable.$converterpriorityn; + map['priority'] = Variable(converter.toSql(priority)); + } + return map; + } + + CategoriesCompanion toCompanion(bool nullToAbsent) { + return CategoriesCompanion( + id: Value(id), + description: Value(description), + priority: Value(priority), + ); + } + + factory Category.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return Category( + id: serializer.fromJson(json['id']), + description: serializer.fromJson(json['description']), + priority: serializer.fromJson(json['priority']), + descriptionInUpperCase: + serializer.fromJson(json['descriptionInUpperCase']), + ); + } + factory Category.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + Category.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'description': serializer.toJson(description), + 'priority': serializer.toJson(priority), + 'descriptionInUpperCase': + serializer.toJson(descriptionInUpperCase), + }; + } + + Category copyWith( + {int? id, + String? description, + CategoryPriority? priority, + String? descriptionInUpperCase}) => + Category( + id: id ?? this.id, + description: description ?? this.description, + priority: priority ?? this.priority, + descriptionInUpperCase: + descriptionInUpperCase ?? this.descriptionInUpperCase, + ); + @override + String toString() { + return (StringBuffer('Category(') + ..write('id: $id, ') + ..write('description: $description, ') + ..write('priority: $priority, ') + ..write('descriptionInUpperCase: $descriptionInUpperCase') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(id, description, priority, descriptionInUpperCase); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is Category && + other.id == this.id && + other.description == this.description && + other.priority == this.priority && + other.descriptionInUpperCase == this.descriptionInUpperCase); } -@override -String toString() {return (StringBuffer('TodosTableCompanion(')..write('id: $id, ')..write('title: $title, ')..write('content: $content, ')..write('targetDate: $targetDate, ')..write('category: $category')..write(')')).toString();} + +class CategoriesCompanion extends UpdateCompanion { + final Value id; + final Value description; + final Value priority; + const CategoriesCompanion({ + this.id = const Value.absent(), + this.description = const Value.absent(), + this.priority = const Value.absent(), + }); + CategoriesCompanion.insert({ + this.id = const Value.absent(), + required String description, + required CategoryPriority priority, + }) : description = Value(description), + priority = Value(priority); + static Insertable custom({ + Expression? id, + Expression? description, + Expression? priority, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (description != null) 'desc': description, + if (priority != null) 'priority': priority, + }); + } + + CategoriesCompanion copyWith( + {Value? id, + Value? description, + Value? priority}) { + return CategoriesCompanion( + id: id ?? this.id, + description: description ?? this.description, + priority: priority ?? this.priority, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (description.present) { + map['desc'] = Variable(description.value); + } + if (priority.present) { + final converter = $CategoriesTable.$converterpriorityn; + map['priority'] = Variable(converter.toSql(priority.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CategoriesCompanion(') + ..write('id: $id, ') + ..write('description: $description, ') + ..write('priority: $priority') + ..write(')')) + .toString(); + } } -class $TodosTableTable extends TodosTable with TableInfo<$TodosTableTable, TodoEntry> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$TodosTableTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _idMeta = const VerificationMeta('id'); -@override -late final GeneratedColumn id = GeneratedColumn('id', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); -final VerificationMeta _titleMeta = const VerificationMeta('title'); -@override -late final GeneratedColumn title = GeneratedColumn('title', aliasedName, true, additionalChecks: GeneratedColumn.checkTextLength(minTextLength: 4,maxTextLength: 16), type: DriftSqlType.string, requiredDuringInsert: false); -final VerificationMeta _contentMeta = const VerificationMeta('content'); -@override -late final GeneratedColumn content = GeneratedColumn('content', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true); -final VerificationMeta _targetDateMeta = const VerificationMeta('targetDate'); -@override -late final GeneratedColumn targetDate = GeneratedColumn('target_date', aliasedName, true, type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultConstraints: 'UNIQUE'); -final VerificationMeta _categoryMeta = const VerificationMeta('category'); -@override -late final GeneratedColumn category = GeneratedColumn('category', aliasedName, true, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: 'REFERENCES categories (id)'); -@override -List get $columns => [id, title, content, targetDate, category]; -@override -String get aliasedName => _alias ?? 'todos'; -@override - String get 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('title')) { -context.handle(_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));}if (data.containsKey('content')) { -context.handle(_contentMeta, content.isAcceptableOrUnknown(data['content']!, _contentMeta));} else if (isInserting) { -context.missing(_contentMeta); + +class $CategoriesTable extends Categories + with TableInfo<$CategoriesTable, Category> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $CategoriesTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); + final VerificationMeta _descriptionMeta = + const VerificationMeta('description'); + @override + late final GeneratedColumn description = GeneratedColumn( + 'desc', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE'); + final VerificationMeta _priorityMeta = const VerificationMeta('priority'); + @override + late final GeneratedColumnWithTypeConverter priority = + GeneratedColumn('priority', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true) + .withConverter( + $CategoriesTable.$converterpriorityn); + final VerificationMeta _descriptionInUpperCaseMeta = + const VerificationMeta('descriptionInUpperCase'); + @override + late final GeneratedColumn descriptionInUpperCase = + GeneratedColumn('description_in_upper_case', aliasedName, false, + generatedAs: GeneratedAs(description.upper(), false), + type: DriftSqlType.string, + requiredDuringInsert: false); + @override + List get $columns => + [id, description, priority, descriptionInUpperCase]; + @override + String get aliasedName => _alias ?? 'categories'; + @override + String get 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); + } + context.handle(_priorityMeta, const VerificationResult.success()); + if (data.containsKey('description_in_upper_case')) { + context.handle( + _descriptionInUpperCaseMeta, + descriptionInUpperCase.isAcceptableOrUnknown( + data['description_in_upper_case']!, _descriptionInUpperCaseMeta)); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + Category map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return Category( + id: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + description: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}desc'])!, + priority: $CategoriesTable.$converterpriorityn.fromSql(attachedDatabase + .options.types + .read(DriftSqlType.int, data['${effectivePrefix}priority'])!), + descriptionInUpperCase: attachedDatabase.options.types.read( + DriftSqlType.string, + data['${effectivePrefix}description_in_upper_case'])!, + ); + } + + @override + $CategoriesTable createAlias(String alias) { + return $CategoriesTable(attachedDatabase, alias); + } + + static TypeConverter $converterpriority = + const EnumIndexConverter(CategoryPriority.values); } -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; + +class User extends DataClass implements Insertable { + final int id; + final String name; + final bool isAwesome; + final Uint8List profilePicture; + final DateTime creationTime; + const User( + {required this.id, + required this.name, + required this.isAwesome, + required this.profilePicture, + required this.creationTime}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + map['is_awesome'] = Variable(isAwesome); + map['profile_picture'] = Variable(profilePicture); + map['creation_time'] = Variable(creationTime); + return map; + } + + UsersCompanion toCompanion(bool nullToAbsent) { + return UsersCompanion( + id: Value(id), + name: Value(name), + isAwesome: Value(isAwesome), + profilePicture: Value(profilePicture), + creationTime: Value(creationTime), + ); + } + + factory User.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + 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']), + ); + } + factory User.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + User.fromJson(DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'isAwesome': serializer.toJson(isAwesome), + 'profilePicture': serializer.toJson(profilePicture), + 'creationTime': serializer.toJson(creationTime), + }; + } + + 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 => Object.hash(id, name, isAwesome, + $driftBlobEquality.hash(profilePicture), creationTime); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is User && + other.id == this.id && + other.name == this.name && + other.isAwesome == this.isAwesome && + $driftBlobEquality.equals( + other.profilePicture, this.profilePicture) && + other.creationTime == this.creationTime); } -@override -Set get $primaryKey => {id}; -@override -List> get uniqueKeys => [{title, category}, -{title, targetDate}, -]; -@override TodoEntry map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return TodoEntry(id: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}id'])!, title: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}title']), content: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}content'])!, targetDate: attachedDatabase.options.types.read(DriftSqlType.dateTime, data['${effectivePrefix}target_date']), category: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}category']), ); -} -@override -$TodosTableTable createAlias(String alias) { -return $TodosTableTable(attachedDatabase, alias);}}class Category extends DataClass implements Insertable { -final int id; -final String description; -final CategoryPriority priority; -final String descriptionInUpperCase; -const Category({required this.id, required this.description, required this.priority, required this.descriptionInUpperCase});@override -Map toColumns(bool nullToAbsent) { -final map = {};map['id'] = Variable(id);map['desc'] = Variable(description);{final converter = $CategoriesTable.$converterpriorityn; -map['priority'] = Variable(converter.toSql(priority));}return map; -} -CategoriesCompanion toCompanion(bool nullToAbsent) { -return CategoriesCompanion(id: Value (id),description: Value (description),priority: Value (priority),); -} -factory Category.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return Category(id: serializer.fromJson(json['id']),description: serializer.fromJson(json['description']),priority: serializer.fromJson(json['priority']),descriptionInUpperCase: serializer.fromJson(json['descriptionInUpperCase']),);} -factory Category.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => Category.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'id': serializer.toJson(id),'description': serializer.toJson(description),'priority': serializer.toJson(priority),'descriptionInUpperCase': serializer.toJson(descriptionInUpperCase),};}Category copyWith({int? id,String? description,CategoryPriority? priority,String? descriptionInUpperCase}) => Category(id: id ?? this.id,description: description ?? this.description,priority: priority ?? this.priority,descriptionInUpperCase: descriptionInUpperCase ?? this.descriptionInUpperCase,);@override -String toString() {return (StringBuffer('Category(')..write('id: $id, ')..write('description: $description, ')..write('priority: $priority, ')..write('descriptionInUpperCase: $descriptionInUpperCase')..write(')')).toString();} -@override - int get hashCode => Object.hash(id, description, priority, descriptionInUpperCase);@override -bool operator ==(Object other) => identical(this, other) || (other is Category && other.id == this.id && other.description == this.description && other.priority == this.priority && other.descriptionInUpperCase == this.descriptionInUpperCase); -}class CategoriesCompanion extends UpdateCompanion { -final Value id; -final Value description; -final Value priority; -const CategoriesCompanion({this.id = const Value.absent(),this.description = const Value.absent(),this.priority = const Value.absent(),}); -CategoriesCompanion.insert({this.id = const Value.absent(),required String description,required CategoryPriority priority,}): description = Value(description), priority = Value(priority); -static Insertable custom({Expression? id, -Expression? description, -Expression? priority, -}) { -return RawValuesInsertable({if (id != null)'id': id,if (description != null)'desc': description,if (priority != null)'priority': priority,}); -}CategoriesCompanion copyWith({Value? id, Value? description, Value? priority}) { -return CategoriesCompanion(id: id ?? this.id,description: description ?? this.description,priority: priority ?? this.priority,); -} -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (id.present) {map['id'] = Variable(id.value);}if (description.present) {map['desc'] = Variable(description.value);}if (priority.present) {final converter = $CategoriesTable.$converterpriorityn; -map['priority'] = Variable(converter.toSql(priority.value));}return map; -} -@override -String toString() {return (StringBuffer('CategoriesCompanion(')..write('id: $id, ')..write('description: $description, ')..write('priority: $priority')..write(')')).toString();} -} -class $CategoriesTable extends Categories with TableInfo<$CategoriesTable, Category> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$CategoriesTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _idMeta = const VerificationMeta('id'); -@override -late final GeneratedColumn id = GeneratedColumn('id', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); -final VerificationMeta _descriptionMeta = const VerificationMeta('description'); -@override -late final GeneratedColumn description = GeneratedColumn('desc', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: true, $customConstraints: 'NOT NULL UNIQUE'); -final VerificationMeta _priorityMeta = const VerificationMeta('priority'); -@override -late final GeneratedColumnWithTypeConverter priority = GeneratedColumn('priority', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true).withConverter($CategoriesTable.$converterpriorityn); -final VerificationMeta _descriptionInUpperCaseMeta = const VerificationMeta('descriptionInUpperCase'); -@override -late final GeneratedColumn descriptionInUpperCase = GeneratedColumn('description_in_upper_case', aliasedName, false, generatedAs: GeneratedAs(description.upper(), false), type: DriftSqlType.string, requiredDuringInsert: false); -@override -List get $columns => [id, description, priority, descriptionInUpperCase]; -@override -String get aliasedName => _alias ?? 'categories'; -@override - String get 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); -} -context.handle(_priorityMeta, const VerificationResult.success());if (data.containsKey('description_in_upper_case')) { -context.handle(_descriptionInUpperCaseMeta, descriptionInUpperCase.isAcceptableOrUnknown(data['description_in_upper_case']!, _descriptionInUpperCaseMeta));}return context; -} -@override -Set get $primaryKey => {id}; -@override Category map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return Category(id: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}id'])!, description: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}desc'])!, priority: $CategoriesTable.$converterpriorityn.fromSql(attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}priority'])!), descriptionInUpperCase: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}description_in_upper_case'])!, ); -} -@override -$CategoriesTable createAlias(String alias) { -return $CategoriesTable(attachedDatabase, alias);}static TypeConverter $converterpriority = const EnumIndexConverter(CategoryPriority.values);}class User extends DataClass implements Insertable { -final int id; -final String name; -final bool isAwesome; -final Uint8List profilePicture; -final DateTime creationTime; -const User({required this.id, required this.name, required this.isAwesome, required this.profilePicture, required this.creationTime});@override -Map toColumns(bool nullToAbsent) { -final map = {};map['id'] = Variable(id);map['name'] = Variable(name);map['is_awesome'] = Variable(isAwesome);map['profile_picture'] = Variable(profilePicture);map['creation_time'] = Variable(creationTime);return map; -} -UsersCompanion toCompanion(bool nullToAbsent) { -return UsersCompanion(id: Value (id),name: Value (name),isAwesome: Value (isAwesome),profilePicture: Value (profilePicture),creationTime: Value (creationTime),); -} -factory User.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -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']),);} -factory User.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => User.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'id': serializer.toJson(id),'name': serializer.toJson(name),'isAwesome': serializer.toJson(isAwesome),'profilePicture': serializer.toJson(profilePicture),'creationTime': serializer.toJson(creationTime),};}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 => Object.hash(id, name, isAwesome, $driftBlobEquality.hash(profilePicture), creationTime);@override -bool operator ==(Object other) => identical(this, other) || (other is User && other.id == this.id && other.name == this.name && other.isAwesome == this.isAwesome && $driftBlobEquality.equals(other.profilePicture, this.profilePicture) && other.creationTime == this.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(),}); -UsersCompanion.insert({this.id = const Value.absent(),required String name,required bool isAwesome,required Uint8List profilePicture,required DateTime creationTime,}): name = Value(name), isAwesome = Value(isAwesome), profilePicture = Value(profilePicture), creationTime = Value(creationTime); -static Insertable custom({Expression? id, -Expression? name, -Expression? isAwesome, -Expression? profilePicture, -Expression? creationTime, -}) { -return RawValuesInsertable({if (id != null)'id': id,if (name != null)'name': name,if (isAwesome != null)'is_awesome': isAwesome,if (profilePicture != null)'profile_picture': profilePicture,if (creationTime != null)'creation_time': creationTime,}); -}UsersCompanion copyWith({Value? id, Value? name, Value? isAwesome, Value? profilePicture, Value? creationTime}) { -return UsersCompanion(id: id ?? this.id,name: name ?? this.name,isAwesome: isAwesome ?? this.isAwesome,profilePicture: profilePicture ?? this.profilePicture,creationTime: creationTime ?? this.creationTime,); -} -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (id.present) {map['id'] = Variable(id.value);}if (name.present) {map['name'] = Variable(name.value);}if (isAwesome.present) {map['is_awesome'] = Variable(isAwesome.value);}if (profilePicture.present) {map['profile_picture'] = Variable(profilePicture.value);}if (creationTime.present) {map['creation_time'] = Variable(creationTime.value);}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 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(), + }); + UsersCompanion.insert({ + this.id = const Value.absent(), + required String name, + required bool isAwesome, + required Uint8List profilePicture, + required DateTime creationTime, + }) : name = Value(name), + isAwesome = Value(isAwesome), + profilePicture = Value(profilePicture), + creationTime = Value(creationTime); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? isAwesome, + Expression? profilePicture, + Expression? creationTime, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (isAwesome != null) 'is_awesome': isAwesome, + if (profilePicture != null) 'profile_picture': profilePicture, + if (creationTime != null) 'creation_time': creationTime, + }); + } + + UsersCompanion copyWith( + {Value? id, + Value? name, + Value? isAwesome, + Value? profilePicture, + Value? creationTime}) { + return UsersCompanion( + id: id ?? this.id, + name: name ?? this.name, + isAwesome: isAwesome ?? this.isAwesome, + profilePicture: profilePicture ?? this.profilePicture, + creationTime: creationTime ?? this.creationTime, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (isAwesome.present) { + map['is_awesome'] = Variable(isAwesome.value); + } + if (profilePicture.present) { + map['profile_picture'] = Variable(profilePicture.value); + } + if (creationTime.present) { + map['creation_time'] = Variable(creationTime.value); + } + 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> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$UsersTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _idMeta = const VerificationMeta('id'); -@override -late final GeneratedColumn id = GeneratedColumn('id', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: false, defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); -final VerificationMeta _nameMeta = const VerificationMeta('name'); -@override -late final GeneratedColumn name = GeneratedColumn('name', aliasedName, false, additionalChecks: GeneratedColumn.checkTextLength(minTextLength: 6,maxTextLength: 32), type: DriftSqlType.string, requiredDuringInsert: true, defaultConstraints: 'UNIQUE'); -final VerificationMeta _isAwesomeMeta = const VerificationMeta('isAwesome'); -@override -late final GeneratedColumn isAwesome = GeneratedColumn('is_awesome', aliasedName, false, type: DriftSqlType.bool, requiredDuringInsert: true, defaultConstraints: 'CHECK (is_awesome IN (0, 1))'); -final VerificationMeta _profilePictureMeta = const VerificationMeta('profilePicture'); -@override -late final GeneratedColumn profilePicture = GeneratedColumn('profile_picture', aliasedName, false, type: DriftSqlType.blob, requiredDuringInsert: true); -final VerificationMeta _creationTimeMeta = const VerificationMeta('creationTime'); -@override -late final GeneratedColumn creationTime = GeneratedColumn('creation_time', aliasedName, false, check: () => creationTime.isBiggerThan(Constant(DateTime.utc(1950))), type: DriftSqlType.dateTime, requiredDuringInsert: true); -@override -List get $columns => [id, name, isAwesome, profilePicture, creationTime]; -@override -String get aliasedName => _alias ?? 'users'; -@override - String get actualTableName => 'users'; -@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); + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $UsersTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: 'PRIMARY KEY AUTOINCREMENT'); + final VerificationMeta _nameMeta = const VerificationMeta('name'); + @override + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, + additionalChecks: + GeneratedColumn.checkTextLength(minTextLength: 6, maxTextLength: 32), + type: DriftSqlType.string, + requiredDuringInsert: true, + defaultConstraints: 'UNIQUE'); + final VerificationMeta _isAwesomeMeta = const VerificationMeta('isAwesome'); + @override + late final GeneratedColumn isAwesome = GeneratedColumn( + 'is_awesome', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + defaultConstraints: 'CHECK (is_awesome IN (0, 1))'); + final VerificationMeta _profilePictureMeta = + const VerificationMeta('profilePicture'); + @override + late final GeneratedColumn profilePicture = + GeneratedColumn('profile_picture', aliasedName, false, + type: DriftSqlType.blob, requiredDuringInsert: true); + final VerificationMeta _creationTimeMeta = + const VerificationMeta('creationTime'); + @override + late final GeneratedColumn creationTime = GeneratedColumn( + 'creation_time', aliasedName, false, + check: () => creationTime.isBiggerThan(Constant(DateTime.utc(1950))), + type: DriftSqlType.dateTime, + requiredDuringInsert: true); + @override + List get $columns => + [id, name, isAwesome, profilePicture, creationTime]; + @override + String get aliasedName => _alias ?? 'users'; + @override + String get actualTableName => 'users'; + @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); + } + if (data.containsKey('is_awesome')) { + context.handle(_isAwesomeMeta, + isAwesome.isAcceptableOrUnknown(data['is_awesome']!, _isAwesomeMeta)); + } else if (isInserting) { + context.missing(_isAwesomeMeta); + } + if (data.containsKey('profile_picture')) { + context.handle( + _profilePictureMeta, + profilePicture.isAcceptableOrUnknown( + data['profile_picture']!, _profilePictureMeta)); + } else if (isInserting) { + context.missing(_profilePictureMeta); + } + if (data.containsKey('creation_time')) { + context.handle( + _creationTimeMeta, + creationTime.isAcceptableOrUnknown( + data['creation_time']!, _creationTimeMeta)); + } else if (isInserting) { + context.missing(_creationTimeMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + User map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return User( + id: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + name: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + isAwesome: attachedDatabase.options.types + .read(DriftSqlType.bool, data['${effectivePrefix}is_awesome'])!, + profilePicture: attachedDatabase.options.types + .read(DriftSqlType.blob, data['${effectivePrefix}profile_picture'])!, + creationTime: attachedDatabase.options.types.read( + DriftSqlType.dateTime, data['${effectivePrefix}creation_time'])!, + ); + } + + @override + $UsersTable createAlias(String alias) { + return $UsersTable(attachedDatabase, alias); + } } -if (data.containsKey('is_awesome')) { -context.handle(_isAwesomeMeta, isAwesome.isAcceptableOrUnknown(data['is_awesome']!, _isAwesomeMeta));} else if (isInserting) { -context.missing(_isAwesomeMeta); + +class SharedTodo extends DataClass implements Insertable { + final int todo; + final int user; + const SharedTodo({required this.todo, required this.user}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['todo'] = Variable(todo); + map['user'] = Variable(user); + return map; + } + + SharedTodosCompanion toCompanion(bool nullToAbsent) { + return SharedTodosCompanion( + todo: Value(todo), + user: Value(user), + ); + } + + factory SharedTodo.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SharedTodo( + todo: serializer.fromJson(json['todo']), + user: serializer.fromJson(json['user']), + ); + } + factory SharedTodo.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + SharedTodo.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'todo': serializer.toJson(todo), + 'user': serializer.toJson(user), + }; + } + + 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 => Object.hash(todo, user); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SharedTodo && + other.todo == this.todo && + other.user == this.user); } -if (data.containsKey('profile_picture')) { -context.handle(_profilePictureMeta, profilePicture.isAcceptableOrUnknown(data['profile_picture']!, _profilePictureMeta));} else if (isInserting) { -context.missing(_profilePictureMeta); + +class SharedTodosCompanion extends UpdateCompanion { + final Value todo; + final Value user; + const SharedTodosCompanion({ + this.todo = const Value.absent(), + this.user = const Value.absent(), + }); + SharedTodosCompanion.insert({ + required int todo, + required int user, + }) : todo = Value(todo), + user = Value(user); + static Insertable custom({ + Expression? todo, + Expression? user, + }) { + return RawValuesInsertable({ + if (todo != null) 'todo': todo, + if (user != null) 'user': user, + }); + } + + SharedTodosCompanion copyWith({Value? todo, Value? user}) { + return SharedTodosCompanion( + todo: todo ?? this.todo, + user: user ?? this.user, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (todo.present) { + map['todo'] = Variable(todo.value); + } + if (user.present) { + map['user'] = Variable(user.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SharedTodosCompanion(') + ..write('todo: $todo, ') + ..write('user: $user') + ..write(')')) + .toString(); + } } -if (data.containsKey('creation_time')) { -context.handle(_creationTimeMeta, creationTime.isAcceptableOrUnknown(data['creation_time']!, _creationTimeMeta));} else if (isInserting) { -context.missing(_creationTimeMeta); + +class $SharedTodosTable extends SharedTodos + with TableInfo<$SharedTodosTable, SharedTodo> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $SharedTodosTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _todoMeta = const VerificationMeta('todo'); + @override + late final GeneratedColumn todo = GeneratedColumn( + 'todo', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + final VerificationMeta _userMeta = const VerificationMeta('user'); + @override + late final GeneratedColumn user = GeneratedColumn( + 'user', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + @override + List get $columns => [todo, user]; + @override + String get aliasedName => _alias ?? 'shared_todos'; + @override + String get actualTableName => 'shared_todos'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('todo')) { + context.handle( + _todoMeta, todo.isAcceptableOrUnknown(data['todo']!, _todoMeta)); + } else if (isInserting) { + context.missing(_todoMeta); + } + if (data.containsKey('user')) { + context.handle( + _userMeta, user.isAcceptableOrUnknown(data['user']!, _userMeta)); + } else if (isInserting) { + context.missing(_userMeta); + } + return context; + } + + @override + Set get $primaryKey => {todo, user}; + @override + SharedTodo map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SharedTodo( + todo: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}todo'])!, + user: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}user'])!, + ); + } + + @override + $SharedTodosTable createAlias(String alias) { + return $SharedTodosTable(attachedDatabase, alias); + } } -return context; -} -@override -Set get $primaryKey => {id}; -@override User map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return User(id: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}id'])!, name: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}name'])!, isAwesome: attachedDatabase.options.types.read(DriftSqlType.bool, data['${effectivePrefix}is_awesome'])!, profilePicture: attachedDatabase.options.types.read(DriftSqlType.blob, data['${effectivePrefix}profile_picture'])!, creationTime: attachedDatabase.options.types.read(DriftSqlType.dateTime, data['${effectivePrefix}creation_time'])!, ); -} -@override -$UsersTable createAlias(String alias) { -return $UsersTable(attachedDatabase, alias);}}class SharedTodo extends DataClass implements Insertable { -final int todo; -final int user; -const SharedTodo({required this.todo, required this.user});@override -Map toColumns(bool nullToAbsent) { -final map = {};map['todo'] = Variable(todo);map['user'] = Variable(user);return map; -} -SharedTodosCompanion toCompanion(bool nullToAbsent) { -return SharedTodosCompanion(todo: Value (todo),user: Value (user),); -} -factory SharedTodo.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return SharedTodo(todo: serializer.fromJson(json['todo']),user: serializer.fromJson(json['user']),);} -factory SharedTodo.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => SharedTodo.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'todo': serializer.toJson(todo),'user': serializer.toJson(user),};}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 => Object.hash(todo, user);@override -bool operator ==(Object other) => identical(this, other) || (other is SharedTodo && other.todo == this.todo && other.user == this.user); -}class SharedTodosCompanion extends UpdateCompanion { -final Value todo; -final Value user; -const SharedTodosCompanion({this.todo = const Value.absent(),this.user = const Value.absent(),}); -SharedTodosCompanion.insert({required int todo,required int user,}): todo = Value(todo), user = Value(user); -static Insertable custom({Expression? todo, -Expression? user, -}) { -return RawValuesInsertable({if (todo != null)'todo': todo,if (user != null)'user': user,}); -}SharedTodosCompanion copyWith({Value? todo, Value? user}) { -return SharedTodosCompanion(todo: todo ?? this.todo,user: user ?? this.user,); -} -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (todo.present) {map['todo'] = Variable(todo.value);}if (user.present) {map['user'] = Variable(user.value);}return map; -} -@override -String toString() {return (StringBuffer('SharedTodosCompanion(')..write('todo: $todo, ')..write('user: $user')..write(')')).toString();} -} -class $SharedTodosTable extends SharedTodos with TableInfo<$SharedTodosTable, SharedTodo> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$SharedTodosTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _todoMeta = const VerificationMeta('todo'); -@override -late final GeneratedColumn todo = GeneratedColumn('todo', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true); -final VerificationMeta _userMeta = const VerificationMeta('user'); -@override -late final GeneratedColumn user = GeneratedColumn('user', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true); -@override -List get $columns => [todo, user]; -@override -String get aliasedName => _alias ?? 'shared_todos'; -@override - String get actualTableName => 'shared_todos'; -@override -VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { -final context = VerificationContext(); -final data = instance.toColumns(true); -if (data.containsKey('todo')) { -context.handle(_todoMeta, todo.isAcceptableOrUnknown(data['todo']!, _todoMeta));} else if (isInserting) { -context.missing(_todoMeta); -} -if (data.containsKey('user')) { -context.handle(_userMeta, user.isAcceptableOrUnknown(data['user']!, _userMeta));} else if (isInserting) { -context.missing(_userMeta); -} -return context; -} -@override -Set get $primaryKey => {todo, user}; -@override SharedTodo map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return SharedTodo(todo: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}todo'])!, user: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}user'])!, ); -} -@override -$SharedTodosTable createAlias(String alias) { -return $SharedTodosTable(attachedDatabase, alias);}}class TableWithoutPKCompanion extends UpdateCompanion { -final Value notReallyAnId; -final Value someFloat; -final Value webSafeInt; -final Value custom; -const TableWithoutPKCompanion({this.notReallyAnId = const Value.absent(),this.someFloat = const Value.absent(),this.webSafeInt = const Value.absent(),this.custom = const Value.absent(),}); -TableWithoutPKCompanion.insert({required int notReallyAnId,required double someFloat,this.webSafeInt = const Value.absent(),this.custom = const Value.absent(),}): notReallyAnId = Value(notReallyAnId), someFloat = Value(someFloat); -static Insertable createCustom({Expression? notReallyAnId, -Expression? someFloat, -Expression? webSafeInt, -Expression? custom, -}) { -return RawValuesInsertable({if (notReallyAnId != null)'not_really_an_id': notReallyAnId,if (someFloat != null)'some_float': someFloat,if (webSafeInt != null)'web_safe_int': webSafeInt,if (custom != null)'custom': custom,}); -}TableWithoutPKCompanion copyWith({Value? notReallyAnId, Value? someFloat, Value? webSafeInt, Value? custom}) { -return TableWithoutPKCompanion(notReallyAnId: notReallyAnId ?? this.notReallyAnId,someFloat: someFloat ?? this.someFloat,webSafeInt: webSafeInt ?? this.webSafeInt,custom: custom ?? this.custom,); -} -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (notReallyAnId.present) {map['not_really_an_id'] = Variable(notReallyAnId.value);}if (someFloat.present) {map['some_float'] = Variable(someFloat.value);}if (webSafeInt.present) {map['web_safe_int'] = Variable(webSafeInt.value);}if (custom.present) {final converter = $TableWithoutPKTable.$convertercustomn; -map['custom'] = Variable(converter.toSql(custom.value));}return map; -} -@override -String toString() {return (StringBuffer('TableWithoutPKCompanion(')..write('notReallyAnId: $notReallyAnId, ')..write('someFloat: $someFloat, ')..write('webSafeInt: $webSafeInt, ')..write('custom: $custom')..write(')')).toString();} + +class TableWithoutPKCompanion extends UpdateCompanion { + final Value notReallyAnId; + final Value someFloat; + final Value webSafeInt; + final Value custom; + const TableWithoutPKCompanion({ + this.notReallyAnId = const Value.absent(), + this.someFloat = const Value.absent(), + this.webSafeInt = const Value.absent(), + this.custom = const Value.absent(), + }); + TableWithoutPKCompanion.insert({ + required int notReallyAnId, + required double someFloat, + this.webSafeInt = const Value.absent(), + this.custom = const Value.absent(), + }) : notReallyAnId = Value(notReallyAnId), + someFloat = Value(someFloat); + static Insertable createCustom({ + Expression? notReallyAnId, + Expression? someFloat, + Expression? webSafeInt, + Expression? custom, + }) { + return RawValuesInsertable({ + if (notReallyAnId != null) 'not_really_an_id': notReallyAnId, + if (someFloat != null) 'some_float': someFloat, + if (webSafeInt != null) 'web_safe_int': webSafeInt, + if (custom != null) 'custom': custom, + }); + } + + TableWithoutPKCompanion copyWith( + {Value? notReallyAnId, + Value? someFloat, + Value? webSafeInt, + Value? custom}) { + return TableWithoutPKCompanion( + notReallyAnId: notReallyAnId ?? this.notReallyAnId, + someFloat: someFloat ?? this.someFloat, + webSafeInt: webSafeInt ?? this.webSafeInt, + custom: custom ?? this.custom, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (notReallyAnId.present) { + map['not_really_an_id'] = Variable(notReallyAnId.value); + } + if (someFloat.present) { + map['some_float'] = Variable(someFloat.value); + } + if (webSafeInt.present) { + map['web_safe_int'] = Variable(webSafeInt.value); + } + if (custom.present) { + final converter = $TableWithoutPKTable.$convertercustomn; + map['custom'] = Variable(converter.toSql(custom.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('TableWithoutPKCompanion(') + ..write('notReallyAnId: $notReallyAnId, ') + ..write('someFloat: $someFloat, ') + ..write('webSafeInt: $webSafeInt, ') + ..write('custom: $custom') + ..write(')')) + .toString(); + } } + class _$CustomRowClassInsertable implements Insertable { -CustomRowClass _object; + CustomRowClass _object; -_$CustomRowClassInsertable(this._object); + _$CustomRowClassInsertable(this._object); -@override -Map toColumns(bool nullToAbsent) { -return TableWithoutPKCompanion( -custom: Value (_object.custom), -webSafeInt: Value (_object.webSafeInt), -).toColumns(false); -} + @override + Map toColumns(bool nullToAbsent) { + return TableWithoutPKCompanion( + custom: Value(_object.custom), + webSafeInt: Value(_object.webSafeInt), + ).toColumns(false); + } } -extension CustomRowClassToInsertable on CustomRowClass {_$CustomRowClassInsertable toInsertable() { -return _$CustomRowClassInsertable(this); +extension CustomRowClassToInsertable on CustomRowClass { + _$CustomRowClassInsertable toInsertable() { + return _$CustomRowClassInsertable(this); + } } + +class $TableWithoutPKTable extends TableWithoutPK + with TableInfo<$TableWithoutPKTable, CustomRowClass> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $TableWithoutPKTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _notReallyAnIdMeta = + const VerificationMeta('notReallyAnId'); + @override + late final GeneratedColumn notReallyAnId = GeneratedColumn( + 'not_really_an_id', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + final VerificationMeta _someFloatMeta = const VerificationMeta('someFloat'); + @override + late final GeneratedColumn someFloat = GeneratedColumn( + 'some_float', aliasedName, false, + type: DriftSqlType.double, requiredDuringInsert: true); + final VerificationMeta _webSafeIntMeta = const VerificationMeta('webSafeInt'); + @override + late final GeneratedColumn webSafeInt = GeneratedColumn( + 'web_safe_int', aliasedName, true, + type: DriftSqlType.bigInt, requiredDuringInsert: false); + final VerificationMeta _customMeta = const VerificationMeta('custom'); + @override + late final GeneratedColumnWithTypeConverter custom = + GeneratedColumn('custom', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: _uuid.v4, + clientDefault: _uuid.v4) + .withConverter( + $TableWithoutPKTable.$convertercustomn); + @override + List get $columns => + [notReallyAnId, someFloat, webSafeInt, custom]; + @override + String get aliasedName => _alias ?? 'table_without_p_k'; + @override + String get actualTableName => 'table_without_p_k'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('not_really_an_id')) { + context.handle( + _notReallyAnIdMeta, + notReallyAnId.isAcceptableOrUnknown( + data['not_really_an_id']!, _notReallyAnIdMeta)); + } else if (isInserting) { + context.missing(_notReallyAnIdMeta); + } + if (data.containsKey('some_float')) { + context.handle(_someFloatMeta, + someFloat.isAcceptableOrUnknown(data['some_float']!, _someFloatMeta)); + } else if (isInserting) { + context.missing(_someFloatMeta); + } + if (data.containsKey('web_safe_int')) { + context.handle( + _webSafeIntMeta, + webSafeInt.isAcceptableOrUnknown( + data['web_safe_int']!, _webSafeIntMeta)); + } + context.handle(_customMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => const {}; + @override + CustomRowClass map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CustomRowClass.map( + attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}not_really_an_id'])!, + attachedDatabase.options.types + .read(DriftSqlType.double, data['${effectivePrefix}some_float'])!, + custom: $TableWithoutPKTable.$convertercustomn.fromSql(attachedDatabase + .options.types + .read(DriftSqlType.string, data['${effectivePrefix}custom'])!), + webSafeInt: attachedDatabase.options.types + .read(DriftSqlType.bigInt, data['${effectivePrefix}web_safe_int']), + ); + } + + @override + $TableWithoutPKTable createAlias(String alias) { + return $TableWithoutPKTable(attachedDatabase, alias); + } + + static TypeConverter $convertercustom = + const CustomConverter(); } -class $TableWithoutPKTable extends TableWithoutPK with TableInfo<$TableWithoutPKTable, CustomRowClass> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$TableWithoutPKTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _notReallyAnIdMeta = const VerificationMeta('notReallyAnId'); -@override -late final GeneratedColumn notReallyAnId = GeneratedColumn('not_really_an_id', aliasedName, false, type: DriftSqlType.int, requiredDuringInsert: true); -final VerificationMeta _someFloatMeta = const VerificationMeta('someFloat'); -@override -late final GeneratedColumn someFloat = GeneratedColumn('some_float', aliasedName, false, type: DriftSqlType.double, requiredDuringInsert: true); -final VerificationMeta _webSafeIntMeta = const VerificationMeta('webSafeInt'); -@override -late final GeneratedColumn webSafeInt = GeneratedColumn('web_safe_int', aliasedName, true, type: DriftSqlType.bigInt, requiredDuringInsert: false); -final VerificationMeta _customMeta = const VerificationMeta('custom'); -@override -late final GeneratedColumnWithTypeConverter custom = GeneratedColumn('custom', aliasedName, false, type: DriftSqlType.string, requiredDuringInsert: false, defaultValue: _uuid.v4, clientDefault: _uuid.v4).withConverter($TableWithoutPKTable.$convertercustomn); -@override -List get $columns => [notReallyAnId, someFloat, webSafeInt, custom]; -@override -String get aliasedName => _alias ?? 'table_without_p_k'; -@override - String get actualTableName => 'table_without_p_k'; -@override -VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { -final context = VerificationContext(); -final data = instance.toColumns(true); -if (data.containsKey('not_really_an_id')) { -context.handle(_notReallyAnIdMeta, notReallyAnId.isAcceptableOrUnknown(data['not_really_an_id']!, _notReallyAnIdMeta));} else if (isInserting) { -context.missing(_notReallyAnIdMeta); + +class PureDefault extends DataClass implements Insertable { + final MyCustomObject? txt; + const PureDefault({this.txt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (!nullToAbsent || txt != null) { + final converter = $PureDefaultsTable.$convertertxt; + map['insert'] = Variable(converter.toSql(txt)); + } + return map; + } + + PureDefaultsCompanion toCompanion(bool nullToAbsent) { + return PureDefaultsCompanion( + txt: txt == null && nullToAbsent ? const Value.absent() : Value(txt), + ); + } + + factory PureDefault.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PureDefault( + txt: $PureDefaultsTable.$convertertxt + .fromJson(serializer.fromJson>(json['txt'])), + ); + } + factory PureDefault.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + PureDefault.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'txt': serializer.toJson?>( + $PureDefaultsTable.$convertertxt.toJson(txt)), + }; + } + + PureDefault copyWith({Value txt = const Value.absent()}) => + PureDefault( + txt: txt.present ? txt.value : this.txt, + ); + @override + String toString() { + return (StringBuffer('PureDefault(') + ..write('txt: $txt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => txt.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || (other is PureDefault && other.txt == this.txt); } -if (data.containsKey('some_float')) { -context.handle(_someFloatMeta, someFloat.isAcceptableOrUnknown(data['some_float']!, _someFloatMeta));} else if (isInserting) { -context.missing(_someFloatMeta); + +class PureDefaultsCompanion extends UpdateCompanion { + final Value txt; + const PureDefaultsCompanion({ + this.txt = const Value.absent(), + }); + PureDefaultsCompanion.insert({ + this.txt = const Value.absent(), + }); + static Insertable custom({ + Expression? txt, + }) { + return RawValuesInsertable({ + if (txt != null) 'insert': txt, + }); + } + + PureDefaultsCompanion copyWith({Value? txt}) { + return PureDefaultsCompanion( + txt: txt ?? this.txt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (txt.present) { + final converter = $PureDefaultsTable.$convertertxt; + map['insert'] = Variable(converter.toSql(txt.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PureDefaultsCompanion(') + ..write('txt: $txt') + ..write(')')) + .toString(); + } } -if (data.containsKey('web_safe_int')) { -context.handle(_webSafeIntMeta, webSafeInt.isAcceptableOrUnknown(data['web_safe_int']!, _webSafeIntMeta));}context.handle(_customMeta, const VerificationResult.success());return context; + +class $PureDefaultsTable extends PureDefaults + with TableInfo<$PureDefaultsTable, PureDefault> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $PureDefaultsTable(this.attachedDatabase, [this._alias]); + final VerificationMeta _txtMeta = const VerificationMeta('txt'); + @override + late final GeneratedColumnWithTypeConverter txt = + GeneratedColumn('insert', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter($PureDefaultsTable.$convertertxt); + @override + List get $columns => [txt]; + @override + String get aliasedName => _alias ?? 'pure_defaults'; + @override + String get actualTableName => 'pure_defaults'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + context.handle(_txtMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {txt}; + @override + PureDefault map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PureDefault( + txt: $PureDefaultsTable.$convertertxt.fromSql(attachedDatabase + .options.types + .read(DriftSqlType.string, data['${effectivePrefix}insert'])), + ); + } + + @override + $PureDefaultsTable createAlias(String alias) { + return $PureDefaultsTable(attachedDatabase, alias); + } + + static JsonTypeConverter $convertertxt = + const CustomJsonConverter(); + static JsonTypeConverter $convertertxtn = + JsonTypeConverter2.asNullable($convertertxt); } -@override -Set get $primaryKey => const {};@override CustomRowClass map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return CustomRowClass.map(attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}not_really_an_id'])!, attachedDatabase.options.types.read(DriftSqlType.double, data['${effectivePrefix}some_float'])!, custom: $TableWithoutPKTable.$convertercustomn.fromSql(attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}custom'])!), webSafeInt: attachedDatabase.options.types.read(DriftSqlType.bigInt, data['${effectivePrefix}web_safe_int']), ); + +class CategoryTodoCountViewData extends DataClass { + final String? description; + final int? itemCount; + const CategoryTodoCountViewData({this.description, this.itemCount}); + factory CategoryTodoCountViewData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CategoryTodoCountViewData( + description: serializer.fromJson(json['description']), + itemCount: serializer.fromJson(json['itemCount']), + ); + } + factory CategoryTodoCountViewData.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + CategoryTodoCountViewData.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'description': serializer.toJson(description), + 'itemCount': serializer.toJson(itemCount), + }; + } + + CategoryTodoCountViewData copyWith( + {Value description = const Value.absent(), + Value itemCount = const Value.absent()}) => + CategoryTodoCountViewData( + description: description.present ? description.value : this.description, + itemCount: itemCount.present ? itemCount.value : this.itemCount, + ); + @override + String toString() { + return (StringBuffer('CategoryTodoCountViewData(') + ..write('description: $description, ') + ..write('itemCount: $itemCount') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(description, itemCount); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CategoryTodoCountViewData && + other.description == this.description && + other.itemCount == this.itemCount); } -@override -$TableWithoutPKTable createAlias(String alias) { -return $TableWithoutPKTable(attachedDatabase, alias);}static TypeConverter $convertercustom = const CustomConverter();}class PureDefault extends DataClass implements Insertable { -final MyCustomObject? txt; -const PureDefault({this.txt});@override -Map toColumns(bool nullToAbsent) { -final map = {};if (!nullToAbsent || txt != null){final converter = $PureDefaultsTable.$convertertxt; -map['insert'] = Variable(converter.toSql(txt));}return map; -} -PureDefaultsCompanion toCompanion(bool nullToAbsent) { -return PureDefaultsCompanion(txt: txt == null && nullToAbsent ? const Value.absent() : Value (txt),); -} -factory PureDefault.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return PureDefault(txt: $PureDefaultsTable.$convertertxt.fromJson(serializer.fromJson>(json['txt'])),);} -factory PureDefault.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => PureDefault.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'txt': serializer.toJson?>($PureDefaultsTable.$convertertxt.toJson(txt)),};}PureDefault copyWith({Value txt = const Value.absent()}) => PureDefault(txt: txt.present ? txt.value : this.txt,);@override -String toString() {return (StringBuffer('PureDefault(')..write('txt: $txt')..write(')')).toString();} -@override - int get hashCode => txt.hashCode;@override -bool operator ==(Object other) => identical(this, other) || (other is PureDefault && other.txt == this.txt); -}class PureDefaultsCompanion extends UpdateCompanion { -final Value txt; -const PureDefaultsCompanion({this.txt = const Value.absent(),}); -PureDefaultsCompanion.insert({this.txt = const Value.absent(),}); -static Insertable custom({Expression? txt, -}) { -return RawValuesInsertable({if (txt != null)'insert': txt,}); -}PureDefaultsCompanion copyWith({Value? txt}) { -return PureDefaultsCompanion(txt: txt ?? this.txt,); -} -@override -Map toColumns(bool nullToAbsent) { -final map = {};if (txt.present) {final converter = $PureDefaultsTable.$convertertxt; -map['insert'] = Variable(converter.toSql(txt.value));}return map; -} -@override -String toString() {return (StringBuffer('PureDefaultsCompanion(')..write('txt: $txt')..write(')')).toString();} -} -class $PureDefaultsTable extends PureDefaults with TableInfo<$PureDefaultsTable, PureDefault> { -@override final GeneratedDatabase attachedDatabase; -final String? _alias; -$PureDefaultsTable(this.attachedDatabase, [this._alias]); -final VerificationMeta _txtMeta = const VerificationMeta('txt'); -@override -late final GeneratedColumnWithTypeConverter txt = GeneratedColumn('insert', aliasedName, true, type: DriftSqlType.string, requiredDuringInsert: false).withConverter($PureDefaultsTable.$convertertxt); -@override -List get $columns => [txt]; -@override -String get aliasedName => _alias ?? 'pure_defaults'; -@override - String get actualTableName => 'pure_defaults'; -@override -VerificationContext validateIntegrity(Insertable instance, {bool isInserting = false}) { -final context = VerificationContext(); -final data = instance.toColumns(true); -context.handle(_txtMeta, const VerificationResult.success());return context; -} -@override -Set get $primaryKey => {txt}; -@override PureDefault map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return PureDefault(txt: $PureDefaultsTable.$convertertxt.fromSql(attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}insert'])), ); -} -@override -$PureDefaultsTable createAlias(String alias) { -return $PureDefaultsTable(attachedDatabase, alias);}static JsonTypeConverter $convertertxt = const CustomJsonConverter();static JsonTypeConverter $convertertxtn = JsonTypeConverter2.asNullable($convertertxt);}class CategoryTodoCountViewData extends DataClass { -final String? description; -final int? itemCount; -const CategoryTodoCountViewData({this.description, this.itemCount});factory CategoryTodoCountViewData.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return CategoryTodoCountViewData(description: serializer.fromJson(json['description']),itemCount: serializer.fromJson(json['itemCount']),);} -factory CategoryTodoCountViewData.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => CategoryTodoCountViewData.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'description': serializer.toJson(description),'itemCount': serializer.toJson(itemCount),};}CategoryTodoCountViewData copyWith({Value description = const Value.absent(),Value itemCount = const Value.absent()}) => CategoryTodoCountViewData(description: description.present ? description.value : this.description,itemCount: itemCount.present ? itemCount.value : this.itemCount,);@override -String toString() {return (StringBuffer('CategoryTodoCountViewData(')..write('description: $description, ')..write('itemCount: $itemCount')..write(')')).toString();} -@override - int get hashCode => Object.hash(description, itemCount);@override -bool operator ==(Object other) => identical(this, other) || (other is CategoryTodoCountViewData && other.description == this.description && other.itemCount == this.itemCount); -}class $CategoryTodoCountViewView extends ViewInfo<$CategoryTodoCountViewView, CategoryTodoCountViewData> implements HasResultSet { -final String? _alias; -@override final _$TodoDb attachedDatabase; -$CategoryTodoCountViewView(this.attachedDatabase, [this._alias]); -$TodosTableTable get todos => attachedDatabase.todosTable.createAlias('t0'); -$CategoriesTable get categories => attachedDatabase.categories.createAlias('t1'); -@override -List get $columns => [description, itemCount]; -@override -String get aliasedName => _alias ?? entityName; -@override - String get entityName=> 'category_todo_count_view'; -@override - String? get createViewStmt => null; -@override -$CategoryTodoCountViewView get asDslTable => this; -@override CategoryTodoCountViewData map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return CategoryTodoCountViewData(description: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}description']), itemCount: attachedDatabase.options.types.read(DriftSqlType.int, data['${effectivePrefix}item_count']), ); -} -late final GeneratedColumn description = GeneratedColumn('description', aliasedName, true, generatedAs: GeneratedAs(categories.description + const Variable('!'), false), type: DriftSqlType.string); -late final GeneratedColumn itemCount = GeneratedColumn('item_count', aliasedName, true, generatedAs: GeneratedAs(todos.id.count(), false), type: DriftSqlType.int); -@override -$CategoryTodoCountViewView createAlias(String alias) { -return $CategoryTodoCountViewView(attachedDatabase, alias);}@override -Query? get query => (attachedDatabase.selectOnly(categories)..addColumns($columns)) .join([innerJoin(todos,todos.category.equalsExp(categories.id))]) ..groupBy([categories.id]); - @override - Set get readTables => const {'todos', 'categories'}; - + +class $CategoryTodoCountViewView + extends ViewInfo<$CategoryTodoCountViewView, CategoryTodoCountViewData> + implements HasResultSet { + final String? _alias; + @override + final _$TodoDb attachedDatabase; + $CategoryTodoCountViewView(this.attachedDatabase, [this._alias]); + $TodosTableTable get todos => attachedDatabase.todosTable.createAlias('t0'); + $CategoriesTable get categories => + attachedDatabase.categories.createAlias('t1'); + @override + List get $columns => [description, itemCount]; + @override + String get aliasedName => _alias ?? entityName; + @override + String get entityName => 'category_todo_count_view'; + @override + String? get createViewStmt => null; + @override + $CategoryTodoCountViewView get asDslTable => this; + @override + CategoryTodoCountViewData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CategoryTodoCountViewData( + description: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}description']), + itemCount: attachedDatabase.options.types + .read(DriftSqlType.int, data['${effectivePrefix}item_count']), + ); + } + + late final GeneratedColumn description = GeneratedColumn( + 'description', aliasedName, true, + generatedAs: + GeneratedAs(categories.description + const Variable('!'), false), + type: DriftSqlType.string); + late final GeneratedColumn itemCount = GeneratedColumn( + 'item_count', aliasedName, true, + generatedAs: GeneratedAs(todos.id.count(), false), + type: DriftSqlType.int); + @override + $CategoryTodoCountViewView createAlias(String alias) { + return $CategoryTodoCountViewView(attachedDatabase, alias); + } + + @override + Query? get query => + (attachedDatabase.selectOnly(categories)..addColumns($columns)) + .join([innerJoin(todos, todos.category.equalsExp(categories.id))]) + ..groupBy([categories.id]); + @override + Set get readTables => const {'todos', 'categories'}; } + class TodoWithCategoryViewData extends DataClass { -final String? title; -final String description; -const TodoWithCategoryViewData({this.title, required this.description});factory TodoWithCategoryViewData.fromJson(Map json, {ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return TodoWithCategoryViewData(title: serializer.fromJson(json['title']),description: serializer.fromJson(json['description']),);} -factory TodoWithCategoryViewData.fromJsonString(String encodedJson, {ValueSerializer? serializer}) => TodoWithCategoryViewData.fromJson(DataClass.parseJson(encodedJson) as Map, serializer: serializer);@override Map toJson({ValueSerializer? serializer}) { -serializer ??= driftRuntimeOptions.defaultSerializer; -return { -'title': serializer.toJson(title),'description': serializer.toJson(description),};}TodoWithCategoryViewData copyWith({Value title = const Value.absent(),String? description}) => TodoWithCategoryViewData(title: title.present ? title.value : this.title,description: description ?? this.description,);@override -String toString() {return (StringBuffer('TodoWithCategoryViewData(')..write('title: $title, ')..write('description: $description')..write(')')).toString();} -@override - int get hashCode => Object.hash(title, description);@override -bool operator ==(Object other) => identical(this, other) || (other is TodoWithCategoryViewData && other.title == this.title && other.description == this.description); -}class $TodoWithCategoryViewView extends ViewInfo<$TodoWithCategoryViewView, TodoWithCategoryViewData> implements HasResultSet { -final String? _alias; -@override final _$TodoDb attachedDatabase; -$TodoWithCategoryViewView(this.attachedDatabase, [this._alias]); -$TodosTableTable get todos => attachedDatabase.todosTable.createAlias('t0'); -$CategoriesTable get categories => attachedDatabase.categories.createAlias('t1'); -@override -List get $columns => [title, description]; -@override -String get aliasedName => _alias ?? entityName; -@override - String get entityName=> 'todo_with_category_view'; -@override - String? get createViewStmt => null; -@override -$TodoWithCategoryViewView get asDslTable => this; -@override TodoWithCategoryViewData map(Map data, {String? tablePrefix}) { -final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';return TodoWithCategoryViewData(title: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}title']), description: attachedDatabase.options.types.read(DriftSqlType.string, data['${effectivePrefix}desc'])!, ); + final String? title; + final String description; + const TodoWithCategoryViewData({this.title, required this.description}); + factory TodoWithCategoryViewData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return TodoWithCategoryViewData( + title: serializer.fromJson(json['title']), + description: serializer.fromJson(json['description']), + ); + } + factory TodoWithCategoryViewData.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + TodoWithCategoryViewData.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'title': serializer.toJson(title), + 'description': serializer.toJson(description), + }; + } + + TodoWithCategoryViewData copyWith( + {Value title = const Value.absent(), String? description}) => + TodoWithCategoryViewData( + title: title.present ? title.value : this.title, + description: description ?? this.description, + ); + @override + String toString() { + return (StringBuffer('TodoWithCategoryViewData(') + ..write('title: $title, ') + ..write('description: $description') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(title, description); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is TodoWithCategoryViewData && + other.title == this.title && + other.description == this.description); } -late final GeneratedColumn title = GeneratedColumn('title', aliasedName, true, generatedAs: GeneratedAs(todos.title, false), type: DriftSqlType.string); -late final GeneratedColumn description = GeneratedColumn('desc', aliasedName, false, generatedAs: GeneratedAs(categories.description, false), type: DriftSqlType.string); -@override -$TodoWithCategoryViewView createAlias(String alias) { -return $TodoWithCategoryViewView(attachedDatabase, alias);}@override -Query? get query => (attachedDatabase.selectOnly(todos)..addColumns($columns)) .join([innerJoin(categories,categories.id.equalsExp(todos.category))]); - @override - Set get readTables => const {'todos', 'categories'}; - -} -abstract class _$TodoDb extends GeneratedDatabase{ -_$TodoDb(QueryExecutor e): super(e); -_$TodoDb.connect(DatabaseConnection c): super.connect(c); -late final $TodosTableTable todosTable = $TodosTableTable(this); -late final $CategoriesTable categories = $CategoriesTable(this); -late final $UsersTable users = $UsersTable(this); -late final $SharedTodosTable sharedTodos = $SharedTodosTable(this); -late final $TableWithoutPKTable tableWithoutPK = $TableWithoutPKTable(this); -late final $PureDefaultsTable pureDefaults = $PureDefaultsTable(this); -late final $CategoryTodoCountViewView categoryTodoCountView = $CategoryTodoCountViewView(this); -late final $TodoWithCategoryViewView todoWithCategoryView = $TodoWithCategoryViewView(this); -late final SomeDao someDao = SomeDao(this as TodoDb); -Selectable allTodosWithCategory() { -return customSelect('SELECT t.*, c.id AS catId, c."desc" AS catDesc FROM todos AS t INNER JOIN categories AS c ON c.id = t.category', variables: [], readsFrom: {categories,todosTable,}).map((QueryRow row) { return AllTodosWithCategoryResult(row: row, -id: row.read('id'),title: row.read('title'),content: row.read('content'),targetDate: row.read('target_date'),category: row.read('category'),catId: row.read('catId'),catDesc: row.read('catDesc'),); -}); -} -Future deleteTodoById(int var1) { -return customUpdate('DELETE FROM todos WHERE id = ?1',variables: [Variable(var1)],updates: {todosTable}, updateKind: UpdateKind.delete,); -} -Selectable withIn(String var1, String var2, int var3) { -var $arrayStartIndex = 3;final expandedvar3 = $expandVar($arrayStartIndex, var3.length); -$arrayStartIndex += var3.length; -return customSelect('SELECT * FROM todos WHERE title = ?2 OR id IN ($expandedvar3) OR title = ?1', variables: [Variable(var1), Variable(var2), for (var $ in var3) Variable($)], readsFrom: {todosTable,}).asyncMap(todosTable.mapFromRow); -} -Selectable search({required int id}) { -return customSelect('SELECT * FROM todos WHERE CASE WHEN -1 = ?1 THEN 1 ELSE id = ?1 END', variables: [Variable(id)], readsFrom: {todosTable,}).asyncMap(todosTable.mapFromRow); -} -Selectable findCustom() { -return customSelect('SELECT custom FROM table_without_p_k WHERE some_float < 10', variables: [], readsFrom: {tableWithoutPK,}).map((QueryRow row) => $TableWithoutPKTable.$convertercustomn.fromSql(row.read('custom'))); + +class $TodoWithCategoryViewView + extends ViewInfo<$TodoWithCategoryViewView, TodoWithCategoryViewData> + implements HasResultSet { + final String? _alias; + @override + final _$TodoDb attachedDatabase; + $TodoWithCategoryViewView(this.attachedDatabase, [this._alias]); + $TodosTableTable get todos => attachedDatabase.todosTable.createAlias('t0'); + $CategoriesTable get categories => + attachedDatabase.categories.createAlias('t1'); + @override + List get $columns => [title, description]; + @override + String get aliasedName => _alias ?? entityName; + @override + String get entityName => 'todo_with_category_view'; + @override + String? get createViewStmt => null; + @override + $TodoWithCategoryViewView get asDslTable => this; + @override + TodoWithCategoryViewData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return TodoWithCategoryViewData( + title: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}title']), + description: attachedDatabase.options.types + .read(DriftSqlType.string, data['${effectivePrefix}desc'])!, + ); + } + + late final GeneratedColumn title = GeneratedColumn( + 'title', aliasedName, true, + generatedAs: GeneratedAs(todos.title, false), type: DriftSqlType.string); + late final GeneratedColumn description = GeneratedColumn( + 'desc', aliasedName, false, + generatedAs: GeneratedAs(categories.description, false), + type: DriftSqlType.string); + @override + $TodoWithCategoryViewView createAlias(String alias) { + return $TodoWithCategoryViewView(attachedDatabase, alias); + } + + @override + Query? get query => (attachedDatabase.selectOnly(todos)..addColumns($columns)) + .join([innerJoin(categories, categories.id.equalsExp(todos.category))]); + @override + Set get readTables => const {'todos', 'categories'}; } + +abstract class _$TodoDb extends GeneratedDatabase { + _$TodoDb(QueryExecutor e) : super(e); + _$TodoDb.connect(DatabaseConnection c) : super.connect(c); + late final $TodosTableTable todosTable = $TodosTableTable(this); + late final $CategoriesTable categories = $CategoriesTable(this); + late final $UsersTable users = $UsersTable(this); + late final $SharedTodosTable sharedTodos = $SharedTodosTable(this); + late final $TableWithoutPKTable tableWithoutPK = $TableWithoutPKTable(this); + late final $PureDefaultsTable pureDefaults = $PureDefaultsTable(this); + late final $CategoryTodoCountViewView categoryTodoCountView = + $CategoryTodoCountViewView(this); + late final $TodoWithCategoryViewView todoWithCategoryView = + $TodoWithCategoryViewView(this); + late final SomeDao someDao = SomeDao(this as TodoDb); + Selectable allTodosWithCategory() { + return customSelect( + 'SELECT t.*, c.id AS catId, c."desc" AS catDesc FROM todos AS t INNER JOIN categories AS c ON c.id = t.category', + variables: [], + readsFrom: { + categories, + todosTable, + }).map((QueryRow row) { + return AllTodosWithCategoryResult( + row: row, + id: row.read('id'), + title: row.read('title'), + content: row.read('content'), + targetDate: row.read('target_date'), + category: row.read('category'), + catId: row.read('catId'), + catDesc: row.read('catDesc'), + ); + }); + } + + Future deleteTodoById(int var1) { + return customUpdate( + 'DELETE FROM todos WHERE id = ?1', + variables: [Variable(var1)], + updates: {todosTable}, + updateKind: UpdateKind.delete, + ); + } + + Selectable withIn(String var1, String var2, int var3) { + var $arrayStartIndex = 3; + final expandedvar3 = $expandVar($arrayStartIndex, var3.length); + $arrayStartIndex += var3.length; + return customSelect( + 'SELECT * FROM todos WHERE title = ?2 OR id IN ($expandedvar3) OR title = ?1', + variables: [ + Variable(var1), + Variable(var2), + for (var $ in var3) Variable($) + ], + readsFrom: { + todosTable, + }).asyncMap(todosTable.mapFromRow); + } + + Selectable search({required int id}) { + return customSelect( + 'SELECT * FROM todos WHERE CASE WHEN -1 = ?1 THEN 1 ELSE id = ?1 END', + variables: [ + Variable(id) + ], + readsFrom: { + todosTable, + }).asyncMap(todosTable.mapFromRow); + } + + Selectable findCustom() { + return customSelect( + 'SELECT custom FROM table_without_p_k WHERE some_float < 10', + variables: [], + readsFrom: { + tableWithoutPK, + }).map((QueryRow row) => $TableWithoutPKTable.$convertercustomn + .fromSql(row.read('custom'))); + } + + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + todosTable, + categories, + users, + sharedTodos, + tableWithoutPK, + pureDefaults, + categoryTodoCountView, + todoWithCategoryView + ]; } + class AllTodosWithCategoryResult extends CustomResultSet { -final int id -;final String title -;final String content -;final DateTime targetDate -;final int category -;final int catId -;final String catDesc -;AllTodosWithCategoryResult({required QueryRow row,required this.id,required this.title,required this.content,required this.targetDate,required this.category,required this.catId,required this.catDesc,}): super(row); -@override int get hashCode => Object.hash(id, title, content, targetDate, category, catId, catDesc); -@override -bool operator ==(Object other) => identical(this, other) || (other is AllTodosWithCategoryResult && other.id == this.id && other.title == this.title && other.content == this.content && other.targetDate == this.targetDate && other.category == this.category && other.catId == this.catId && other.catDesc == this.catDesc); -@override -String toString() {return (StringBuffer('AllTodosWithCategoryResult(')..write('id: $id, ')..write('title: $title, ')..write('content: $content, ')..write('targetDate: $targetDate, ')..write('category: $category, ')..write('catId: $catId, ')..write('catDesc: $catDesc')..write(')')).toString();} + final int id; + final String title; + final String content; + final DateTime targetDate; + final int category; + final int catId; + final String catDesc; + AllTodosWithCategoryResult({ + required QueryRow row, + required this.id, + required this.title, + required this.content, + required this.targetDate, + required this.category, + required this.catId, + required this.catDesc, + }) : super(row); + @override + int get hashCode => + Object.hash(id, title, content, targetDate, category, catId, catDesc); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AllTodosWithCategoryResult && + other.id == this.id && + other.title == this.title && + other.content == this.content && + other.targetDate == this.targetDate && + other.category == this.category && + other.catId == this.catId && + other.catDesc == this.catDesc); + @override + String toString() { + return (StringBuffer('AllTodosWithCategoryResult(') + ..write('id: $id, ') + ..write('title: $title, ') + ..write('content: $content, ') + ..write('targetDate: $targetDate, ') + ..write('category: $category, ') + ..write('catId: $catId, ') + ..write('catDesc: $catDesc') + ..write(')')) + .toString(); + } } // DriftElementId(asset:drift/test/generated/todos.dart, users) // DriftElementId(asset:drift/test/generated/todos.dart, shared_todos) diff --git a/drift_dev/lib/src/analysis/resolver/file_analysis.dart b/drift_dev/lib/src/analysis/resolver/file_analysis.dart index ff599c2d..07289360 100644 --- a/drift_dev/lib/src/analysis/resolver/file_analysis.dart +++ b/drift_dev/lib/src/analysis/resolver/file_analysis.dart @@ -85,12 +85,15 @@ class FileAnalyzer { } else if (element is DriftView) { final source = element.source; if (source is SqlViewSource) { - final stmt = parsedFile.statements - .whereType() - .firstWhere( - (e) => e.firstPosition == element.declaration.offset); - source.parsedStatement = stmt; + source.parsedStatement = + parsedFile.findStatement(element.declaration); } + } else if (element is DriftTrigger) { + element.parsedStatement = + parsedFile.findStatement(element.declaration); + } else if (element is DriftIndex) { + element.parsedStatement = + parsedFile.findStatement(element.declaration); } } } @@ -152,3 +155,11 @@ class _OptionsAndRequiredVariables { _OptionsAndRequiredVariables(this.options, this.variables); } + +extension on DriftFile { + Node findStatement(DriftDeclaration declaration) { + return statements + .whereType() + .firstWhere((e) => e.firstPosition == declaration.offset); + } +} diff --git a/drift_dev/lib/src/analysis/results/index.dart b/drift_dev/lib/src/analysis/results/index.dart index 1653536f..90b1aac1 100644 --- a/drift_dev/lib/src/analysis/results/index.dart +++ b/drift_dev/lib/src/analysis/results/index.dart @@ -1,3 +1,5 @@ +import 'package:sqlparser/sqlparser.dart'; + import 'element.dart'; import 'table.dart'; @@ -30,4 +32,10 @@ class DriftIndex extends DriftSchemaElement { @override Iterable get references => [if (table != null) table!]; + + /// The parsed `CREATE VIEW` statement from [createView]. + /// + /// This node is not serialized and only set in the late-state, local file + /// analysis. + CreateIndexStatement? parsedStatement; } diff --git a/drift_dev/lib/src/analysis/results/trigger.dart b/drift_dev/lib/src/analysis/results/trigger.dart index dd560614..fa62ce1b 100644 --- a/drift_dev/lib/src/analysis/results/trigger.dart +++ b/drift_dev/lib/src/analysis/results/trigger.dart @@ -1,4 +1,5 @@ import 'package:drift/drift.dart'; +import 'package:sqlparser/sqlparser.dart'; import 'element.dart'; import 'query.dart'; @@ -32,4 +33,10 @@ class DriftTrigger extends DriftSchemaElement { @override String get dbGetterName => DriftSchemaElement.dbFieldName(id.name); + + /// The parsed `CREATE VIEW` statement from [createView]. + /// + /// This node is not serialized and only set in the late-state, local file + /// analysis. + CreateTriggerStatement? parsedStatement; } diff --git a/drift_dev/lib/src/writer/database_writer.dart b/drift_dev/lib/src/writer/database_writer.dart index 340e323e..a3f8af83 100644 --- a/drift_dev/lib/src/writer/database_writer.dart +++ b/drift_dev/lib/src/writer/database_writer.dart @@ -80,24 +80,27 @@ class DatabaseWriter { returnType: tableClassName, code: '$tableClassName(this)', ); - } /* else if (entity is DriftTrigger) { + } else if (entity is DriftTrigger) { + final sql = scope.sqlCode(entity.parsedStatement!); + writeMemoizedGetter( buffer: dbScope.leaf().buffer, getterName: entity.dbGetterName, returnType: 'Trigger', - code: 'Trigger(${asDartLiteral(entity.createSql(scope.options))}, ' - '${asDartLiteral(entity.displayName)})', + code: 'Trigger(${asDartLiteral(sql)}, ' + '${asDartLiteral(entity.schemaName)})', ); } else if (entity is DriftIndex) { + final sql = scope.sqlCode(entity.parsedStatement!); + writeMemoizedGetter( buffer: dbScope.leaf().buffer, getterName: entity.dbGetterName, returnType: 'Index', - code: 'Index(${asDartLiteral(entity.displayName)}, ' - '${asDartLiteral(entity.createSql(scope.options))})', + code: 'Index(${asDartLiteral(entity.schemaName)}, ' + '${asDartLiteral(sql)})', ); - } */ - else if (entity is DriftView) { + } else if (entity is DriftView) { writeMemoizedGetter( buffer: dbScope.leaf().buffer, getterName: entity.dbGetterName, @@ -130,7 +133,7 @@ class DatabaseWriter { // Write List of tables final schemaScope = dbScope.leaf(); -/* + schemaScope ..write( '@override\nIterable> get allTables => ') @@ -139,17 +142,16 @@ class DatabaseWriter { ..write('=> ['); schemaScope - ..write(db.entities.map((e) { - if (e is SpecialQuery) { - final sql = e.formattedSql(scope.options); - return 'OnCreateQuery(${asDartLiteral(sql)})'; - } + ..write(db.references.map((e) { +// if (e is SpecialQuery) { +// final sql = e.formattedSql(scope.options); +// return 'OnCreateQuery(${asDartLiteral(sql)})'; +// } return entityGetters[e]; }).join(', ')) // close list literal and allSchemaEntities getter ..write('];\n'); -*/ final updateRules = FindStreamUpdateRules(db).identifyRules(); if (updateRules.rules.isNotEmpty) { diff --git a/drift_dev/lib/src/writer/queries/query_writer.dart b/drift_dev/lib/src/writer/queries/query_writer.dart index d01cd667..5dc376f2 100644 --- a/drift_dev/lib/src/writer/queries/query_writer.dart +++ b/drift_dev/lib/src/writer/queries/query_writer.dart @@ -156,7 +156,8 @@ class QueryWriter { final dartLiteral = asDartLiteral(specialName ?? column.name); final method = column.nullable ? 'readNullable' : 'read'; - final rawDartType = dartTypeNames[column.sqlType]; + final rawDartType = + _emitter.dartCode(AnnotatedDartCode([dartTypeNames[column.sqlType]!])); var code = 'row.$method<$rawDartType>($dartLiteral)'; final converter = column.typeConverter; diff --git a/drift_dev/lib/src/writer/writer.dart b/drift_dev/lib/src/writer/writer.dart index 3f61a43c..cdcfa835 100644 --- a/drift_dev/lib/src/writer/writer.dart +++ b/drift_dev/lib/src/writer/writer.dart @@ -163,6 +163,10 @@ abstract class _NodeOrWriter { return buffer.toString(); } + + String sqlCode(sql.AstNode node) { + return SqlWriter(writer.options, escapeForDart: false).writeSql(node); + } } abstract class _Node extends _NodeOrWriter {