// ignore_for_file: type=lint import 'package:drift/drift.dart' as i0; import 'package:modular/src/search.drift.dart' as i1; import 'package:drift/internal/modular.dart' as i2; import 'package:modular/src/posts.drift.dart' as i3; class SearchInPost extends i0.DataClass implements i0.Insertable { final String author; final String content; const SearchInPost({required this.author, required this.content}); @override Map toColumns(bool nullToAbsent) { final map = {}; map['author'] = i0.Variable(author); map['content'] = i0.Variable(content); return map; } i1.SearchInPostsCompanion toCompanion(bool nullToAbsent) { return i1.SearchInPostsCompanion( author: i0.Value(author), content: i0.Value(content), ); } factory SearchInPost.fromJson(Map json, {i0.ValueSerializer? serializer}) { serializer ??= i0.driftRuntimeOptions.defaultSerializer; return SearchInPost( author: serializer.fromJson(json['author']), content: serializer.fromJson(json['content']), ); } @override Map toJson({i0.ValueSerializer? serializer}) { serializer ??= i0.driftRuntimeOptions.defaultSerializer; return { 'author': serializer.toJson(author), 'content': serializer.toJson(content), }; } i1.SearchInPost copyWith({String? author, String? content}) => i1.SearchInPost( author: author ?? this.author, content: content ?? this.content, ); @override String toString() { return (StringBuffer('SearchInPost(') ..write('author: $author, ') ..write('content: $content') ..write(')')) .toString(); } @override int get hashCode => Object.hash(author, content); @override bool operator ==(Object other) => identical(this, other) || (other is i1.SearchInPost && other.author == this.author && other.content == this.content); } class SearchInPostsCompanion extends i0.UpdateCompanion { final i0.Value author; final i0.Value content; const SearchInPostsCompanion({ this.author = const i0.Value.absent(), this.content = const i0.Value.absent(), }); SearchInPostsCompanion.insert({ required String author, required String content, }) : author = i0.Value(author), content = i0.Value(content); static i0.Insertable custom({ i0.Expression? author, i0.Expression? content, }) { return i0.RawValuesInsertable({ if (author != null) 'author': author, if (content != null) 'content': content, }); } i1.SearchInPostsCompanion copyWith( {i0.Value? author, i0.Value? content}) { return i1.SearchInPostsCompanion( author: author ?? this.author, content: content ?? this.content, ); } @override Map toColumns(bool nullToAbsent) { final map = {}; if (author.present) { map['author'] = i0.Variable(author.value); } if (content.present) { map['content'] = i0.Variable(content.value); } return map; } @override String toString() { return (StringBuffer('i1.SearchInPostsCompanion(') ..write('author: $author, ') ..write('content: $content') ..write(')')) .toString(); } } class SearchInPosts extends i0.Table with i0.TableInfo, i0.VirtualTableInfo { @override final i0.GeneratedDatabase attachedDatabase; final String? _alias; SearchInPosts(this.attachedDatabase, [this._alias]); static const i0.VerificationMeta _authorMeta = const i0.VerificationMeta('author'); late final i0.GeneratedColumn author = i0.GeneratedColumn( 'author', aliasedName, false, type: i0.DriftSqlType.string, requiredDuringInsert: true, $customConstraints: ''); static const i0.VerificationMeta _contentMeta = const i0.VerificationMeta('content'); late final i0.GeneratedColumn content = i0.GeneratedColumn( 'content', aliasedName, false, type: i0.DriftSqlType.string, requiredDuringInsert: true, $customConstraints: ''); @override List get $columns => [author, content]; @override String get aliasedName => _alias ?? 'search_in_posts'; @override String get actualTableName => 'search_in_posts'; @override i0.VerificationContext validateIntegrity( i0.Insertable instance, {bool isInserting = false}) { final context = i0.VerificationContext(); final data = instance.toColumns(true); if (data.containsKey('author')) { context.handle(_authorMeta, author.isAcceptableOrUnknown(data['author']!, _authorMeta)); } else if (isInserting) { context.missing(_authorMeta); } if (data.containsKey('content')) { context.handle(_contentMeta, content.isAcceptableOrUnknown(data['content']!, _contentMeta)); } else if (isInserting) { context.missing(_contentMeta); } return context; } @override Set get $primaryKey => const {}; @override i1.SearchInPost map(Map data, {String? tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; return i1.SearchInPost( author: attachedDatabase.typeMapping .read(i0.DriftSqlType.string, data['${effectivePrefix}author'])!, content: attachedDatabase.typeMapping .read(i0.DriftSqlType.string, data['${effectivePrefix}content'])!, ); } @override SearchInPosts createAlias(String alias) { return SearchInPosts(attachedDatabase, alias); } @override List get customConstraints => const []; @override bool get dontWriteConstraints => true; @override String get moduleAndArgs => 'fts5(author, content, content=posts, content_rowid=id)'; } i0.Trigger get postsInsert => i0.Trigger( 'CREATE TRIGGER posts_insert AFTER INSERT ON posts BEGIN INSERT INTO search_in_posts ("rowid", author, content) VALUES (new.id, new.author, new.content);END', 'posts_insert'); i0.Trigger get postsUpdate => i0.Trigger( 'CREATE TRIGGER posts_update AFTER UPDATE ON posts BEGIN INSERT INTO search_in_posts (search_in_posts, "rowid", author, content) VALUES (\'delete\', old.id, old.author, old.content);INSERT INTO search_in_posts ("rowid", author, content) VALUES (new.id, new.author, new.content);END', 'posts_update'); i0.Trigger get postsDelete => i0.Trigger( 'CREATE TRIGGER posts_delete AFTER DELETE ON posts BEGIN INSERT INTO search_in_posts (search_in_posts, "rowid", author, content) VALUES (\'delete\', old.id, old.author, old.content);END', 'posts_delete'); class SearchDrift extends i2.ModularAccessor { SearchDrift(i0.GeneratedDatabase db) : super(db); i0.Selectable search(String var1) { return customSelect( 'WITH relevant_ports AS (SELECT "rowid" FROM search_in_posts WHERE search_in_posts MATCH ?1) SELECT posts.* FROM relevant_ports AS results INNER JOIN posts ON id = results."rowid"', variables: [ i0.Variable(var1) ], readsFrom: { searchInPosts, posts, }).asyncMap(posts.mapFromRow); } i1.SearchInPosts get searchInPosts => this.resultSet('search_in_posts'); i3.Posts get posts => this.resultSet('posts'); }