diff --git a/drift/test/generated/todos.dart b/drift/test/generated/todos.dart index 0b0a6c28..3e4ba9af 100644 --- a/drift/test/generated/todos.dart +++ b/drift/test/generated/todos.dart @@ -24,9 +24,6 @@ class TodosTable extends Table with AutoIncrement { @JsonKey('target_date') DateTimeColumn get targetDate => dateTime().nullable().unique()(); - RealColumn get someFloat => real().nullable()(); - Int64Column get someInt64 => int64().nullable()(); - IntColumn get category => integer().references(Categories, #id).nullable()(); TextColumn get status => textEnum().nullable()(); @@ -90,6 +87,22 @@ class TableWithoutPK extends Table { text().map(const CustomConverter()).clientDefault(_uuid.v4)(); } +class TableWithEveryColumnType extends Table with AutoIncrement { + BoolColumn get aBool => boolean().nullable()(); + DateTimeColumn get aDateTime => dateTime().nullable()(); + TextColumn get aText => text().nullable()(); + IntColumn get anInt => integer().nullable()(); + Int64Column get anInt64 => int64().nullable()(); + RealColumn get aReal => real().nullable()(); + BlobColumn get aBlob => blob().nullable()(); + IntColumn get anIntEnum => intEnum().nullable()(); + TextColumn get aTextWithConverter => text() + .named('insert') + .map(const CustomJsonConverter()) + .nullable() + .nullable()(); +} + class CustomRowClass { final int notReallyAnId; final double anotherName; @@ -251,6 +264,7 @@ const uuidType = DialectAwareSqlType.via( TableWithoutPK, PureDefaults, WithCustomType, + TableWithEveryColumnType ], views: [ CategoryTodoCountView, diff --git a/drift/test/generated/todos.g.dart b/drift/test/generated/todos.g.dart index 154b5be7..233e26b1 100644 --- a/drift/test/generated/todos.g.dart +++ b/drift/test/generated/todos.g.dart @@ -305,18 +305,6 @@ class $TodosTableTable extends TodosTable type: DriftSqlType.dateTime, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE')); - static const VerificationMeta _someFloatMeta = - const VerificationMeta('someFloat'); - @override - late final GeneratedColumn someFloat = GeneratedColumn( - 'some_float', aliasedName, true, - type: DriftSqlType.double, requiredDuringInsert: false); - static const VerificationMeta _someInt64Meta = - const VerificationMeta('someInt64'); - @override - late final GeneratedColumn someInt64 = GeneratedColumn( - 'some_int64', aliasedName, true, - type: DriftSqlType.bigInt, requiredDuringInsert: false); static const VerificationMeta _categoryMeta = const VerificationMeta('category'); @override @@ -334,7 +322,7 @@ class $TodosTableTable extends TodosTable .withConverter($TodosTableTable.$converterstatusn); @override List get $columns => - [id, title, content, targetDate, someFloat, someInt64, category, status]; + [id, title, content, targetDate, category, status]; @override String get aliasedName => _alias ?? actualTableName; @override @@ -362,14 +350,6 @@ class $TodosTableTable extends TodosTable targetDate.isAcceptableOrUnknown( data['target_date']!, _targetDateMeta)); } - if (data.containsKey('some_float')) { - context.handle(_someFloatMeta, - someFloat.isAcceptableOrUnknown(data['some_float']!, _someFloatMeta)); - } - if (data.containsKey('some_int64')) { - context.handle(_someInt64Meta, - someInt64.isAcceptableOrUnknown(data['some_int64']!, _someInt64Meta)); - } if (data.containsKey('category')) { context.handle(_categoryMeta, category.isAcceptableOrUnknown(data['category']!, _categoryMeta)); @@ -397,10 +377,6 @@ class $TodosTableTable extends TodosTable .read(DriftSqlType.string, data['${effectivePrefix}content'])!, targetDate: attachedDatabase.typeMapping .read(DriftSqlType.dateTime, data['${effectivePrefix}target_date']), - someFloat: attachedDatabase.typeMapping - .read(DriftSqlType.double, data['${effectivePrefix}some_float']), - someInt64: attachedDatabase.typeMapping - .read(DriftSqlType.bigInt, data['${effectivePrefix}some_int64']), category: attachedDatabase.typeMapping .read(DriftSqlType.int, data['${effectivePrefix}category']), status: $TodosTableTable.$converterstatusn.fromSql(attachedDatabase @@ -427,8 +403,6 @@ class TodoEntry extends DataClass implements Insertable { final String? title; final String content; final DateTime? targetDate; - final double? someFloat; - final BigInt? someInt64; final int? category; final TodoStatus? status; const TodoEntry( @@ -436,8 +410,6 @@ class TodoEntry extends DataClass implements Insertable { this.title, required this.content, this.targetDate, - this.someFloat, - this.someInt64, this.category, this.status}); @override @@ -453,12 +425,6 @@ class TodoEntry extends DataClass implements Insertable { if (!nullToAbsent || targetDate != null) { map['target_date'] = Variable(targetDate); } - if (!nullToAbsent || someFloat != null) { - map['some_float'] = Variable(someFloat); - } - if (!nullToAbsent || someInt64 != null) { - map['some_int64'] = Variable(someInt64); - } if (!nullToAbsent || category != null) { map['category'] = Variable(category); } @@ -478,12 +444,6 @@ class TodoEntry extends DataClass implements Insertable { targetDate: targetDate == null && nullToAbsent ? const Value.absent() : Value(targetDate), - someFloat: someFloat == null && nullToAbsent - ? const Value.absent() - : Value(someFloat), - someInt64: someInt64 == null && nullToAbsent - ? const Value.absent() - : Value(someInt64), category: category == null && nullToAbsent ? const Value.absent() : Value(category), @@ -501,8 +461,6 @@ class TodoEntry extends DataClass implements Insertable { title: serializer.fromJson(json['title']), content: serializer.fromJson(json['content']), targetDate: serializer.fromJson(json['target_date']), - someFloat: serializer.fromJson(json['someFloat']), - someInt64: serializer.fromJson(json['someInt64']), category: serializer.fromJson(json['category']), status: $TodosTableTable.$converterstatusn .fromJson(serializer.fromJson(json['status'])), @@ -521,8 +479,6 @@ class TodoEntry extends DataClass implements Insertable { 'title': serializer.toJson(title), 'content': serializer.toJson(content), 'target_date': serializer.toJson(targetDate), - 'someFloat': serializer.toJson(someFloat), - 'someInt64': serializer.toJson(someInt64), 'category': serializer.toJson(category), 'status': serializer .toJson($TodosTableTable.$converterstatusn.toJson(status)), @@ -534,8 +490,6 @@ class TodoEntry extends DataClass implements Insertable { Value title = const Value.absent(), String? content, Value targetDate = const Value.absent(), - Value someFloat = const Value.absent(), - Value someInt64 = const Value.absent(), Value category = const Value.absent(), Value status = const Value.absent()}) => TodoEntry( @@ -543,8 +497,6 @@ class TodoEntry extends DataClass implements Insertable { title: title.present ? title.value : this.title, content: content ?? this.content, targetDate: targetDate.present ? targetDate.value : this.targetDate, - someFloat: someFloat.present ? someFloat.value : this.someFloat, - someInt64: someInt64.present ? someInt64.value : this.someInt64, category: category.present ? category.value : this.category, status: status.present ? status.value : this.status, ); @@ -555,8 +507,6 @@ class TodoEntry extends DataClass implements Insertable { ..write('title: $title, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') - ..write('someFloat: $someFloat, ') - ..write('someInt64: $someInt64, ') ..write('category: $category, ') ..write('status: $status') ..write(')')) @@ -564,8 +514,8 @@ class TodoEntry extends DataClass implements Insertable { } @override - int get hashCode => Object.hash( - id, title, content, targetDate, someFloat, someInt64, category, status); + int get hashCode => + Object.hash(id, title, content, targetDate, category, status); @override bool operator ==(Object other) => identical(this, other) || @@ -574,8 +524,6 @@ class TodoEntry extends DataClass implements Insertable { other.title == this.title && other.content == this.content && other.targetDate == this.targetDate && - other.someFloat == this.someFloat && - other.someInt64 == this.someInt64 && other.category == this.category && other.status == this.status); } @@ -585,8 +533,6 @@ class TodosTableCompanion extends UpdateCompanion { final Value title; final Value content; final Value targetDate; - final Value someFloat; - final Value someInt64; final Value category; final Value status; const TodosTableCompanion({ @@ -594,8 +540,6 @@ class TodosTableCompanion extends UpdateCompanion { this.title = const Value.absent(), this.content = const Value.absent(), this.targetDate = const Value.absent(), - this.someFloat = const Value.absent(), - this.someInt64 = const Value.absent(), this.category = const Value.absent(), this.status = const Value.absent(), }); @@ -604,8 +548,6 @@ class TodosTableCompanion extends UpdateCompanion { this.title = const Value.absent(), required String content, this.targetDate = const Value.absent(), - this.someFloat = const Value.absent(), - this.someInt64 = const Value.absent(), this.category = const Value.absent(), this.status = const Value.absent(), }) : content = Value(content); @@ -614,8 +556,6 @@ class TodosTableCompanion extends UpdateCompanion { Expression? title, Expression? content, Expression? targetDate, - Expression? someFloat, - Expression? someInt64, Expression? category, Expression? status, }) { @@ -624,8 +564,6 @@ class TodosTableCompanion extends UpdateCompanion { if (title != null) 'title': title, if (content != null) 'content': content, if (targetDate != null) 'target_date': targetDate, - if (someFloat != null) 'some_float': someFloat, - if (someInt64 != null) 'some_int64': someInt64, if (category != null) 'category': category, if (status != null) 'status': status, }); @@ -636,8 +574,6 @@ class TodosTableCompanion extends UpdateCompanion { Value? title, Value? content, Value? targetDate, - Value? someFloat, - Value? someInt64, Value? category, Value? status}) { return TodosTableCompanion( @@ -645,8 +581,6 @@ class TodosTableCompanion extends UpdateCompanion { title: title ?? this.title, content: content ?? this.content, targetDate: targetDate ?? this.targetDate, - someFloat: someFloat ?? this.someFloat, - someInt64: someInt64 ?? this.someInt64, category: category ?? this.category, status: status ?? this.status, ); @@ -667,12 +601,6 @@ class TodosTableCompanion extends UpdateCompanion { if (targetDate.present) { map['target_date'] = Variable(targetDate.value); } - if (someFloat.present) { - map['some_float'] = Variable(someFloat.value); - } - if (someInt64.present) { - map['some_int64'] = Variable(someInt64.value); - } if (category.present) { map['category'] = Variable(category.value); } @@ -690,8 +618,6 @@ class TodosTableCompanion extends UpdateCompanion { ..write('title: $title, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') - ..write('someFloat: $someFloat, ') - ..write('someInt64: $someInt64, ') ..write('category: $category, ') ..write('status: $status') ..write(')')) @@ -1714,6 +1640,538 @@ class WithCustomTypeCompanion extends UpdateCompanion { } } +class $TableWithEveryColumnTypeTable extends TableWithEveryColumnType + with + TableInfo<$TableWithEveryColumnTypeTable, + TableWithEveryColumnTypeData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $TableWithEveryColumnTypeTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumnWithTypeConverter id = GeneratedColumn< + int>('id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')) + .withConverter($TableWithEveryColumnTypeTable.$converterid); + static const VerificationMeta _aBoolMeta = const VerificationMeta('aBool'); + @override + late final GeneratedColumn aBool = GeneratedColumn( + 'a_bool', aliasedName, true, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('CHECK ("a_bool" IN (0, 1))')); + static const VerificationMeta _aDateTimeMeta = + const VerificationMeta('aDateTime'); + @override + late final GeneratedColumn aDateTime = GeneratedColumn( + 'a_date_time', aliasedName, true, + type: DriftSqlType.dateTime, requiredDuringInsert: false); + static const VerificationMeta _aTextMeta = const VerificationMeta('aText'); + @override + late final GeneratedColumn aText = GeneratedColumn( + 'a_text', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false); + static const VerificationMeta _anIntMeta = const VerificationMeta('anInt'); + @override + late final GeneratedColumn anInt = GeneratedColumn( + 'an_int', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false); + static const VerificationMeta _anInt64Meta = + const VerificationMeta('anInt64'); + @override + late final GeneratedColumn anInt64 = GeneratedColumn( + 'an_int64', aliasedName, true, + type: DriftSqlType.bigInt, requiredDuringInsert: false); + static const VerificationMeta _aRealMeta = const VerificationMeta('aReal'); + @override + late final GeneratedColumn aReal = GeneratedColumn( + 'a_real', aliasedName, true, + type: DriftSqlType.double, requiredDuringInsert: false); + static const VerificationMeta _aBlobMeta = const VerificationMeta('aBlob'); + @override + late final GeneratedColumn aBlob = GeneratedColumn( + 'a_blob', aliasedName, true, + type: DriftSqlType.blob, requiredDuringInsert: false); + static const VerificationMeta _anIntEnumMeta = + const VerificationMeta('anIntEnum'); + @override + late final GeneratedColumnWithTypeConverter anIntEnum = + GeneratedColumn('an_int_enum', aliasedName, true, + type: DriftSqlType.int, requiredDuringInsert: false) + .withConverter( + $TableWithEveryColumnTypeTable.$converteranIntEnumn); + static const VerificationMeta _aTextWithConverterMeta = + const VerificationMeta('aTextWithConverter'); + @override + late final GeneratedColumnWithTypeConverter + aTextWithConverter = GeneratedColumn('insert', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter( + $TableWithEveryColumnTypeTable.$converteraTextWithConvertern); + @override + List get $columns => [ + id, + aBool, + aDateTime, + aText, + anInt, + anInt64, + aReal, + aBlob, + anIntEnum, + aTextWithConverter + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'table_with_every_column_type'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + context.handle(_idMeta, const VerificationResult.success()); + if (data.containsKey('a_bool')) { + context.handle( + _aBoolMeta, aBool.isAcceptableOrUnknown(data['a_bool']!, _aBoolMeta)); + } + if (data.containsKey('a_date_time')) { + context.handle( + _aDateTimeMeta, + aDateTime.isAcceptableOrUnknown( + data['a_date_time']!, _aDateTimeMeta)); + } + if (data.containsKey('a_text')) { + context.handle( + _aTextMeta, aText.isAcceptableOrUnknown(data['a_text']!, _aTextMeta)); + } + if (data.containsKey('an_int')) { + context.handle( + _anIntMeta, anInt.isAcceptableOrUnknown(data['an_int']!, _anIntMeta)); + } + if (data.containsKey('an_int64')) { + context.handle(_anInt64Meta, + anInt64.isAcceptableOrUnknown(data['an_int64']!, _anInt64Meta)); + } + if (data.containsKey('a_real')) { + context.handle( + _aRealMeta, aReal.isAcceptableOrUnknown(data['a_real']!, _aRealMeta)); + } + if (data.containsKey('a_blob')) { + context.handle( + _aBlobMeta, aBlob.isAcceptableOrUnknown(data['a_blob']!, _aBlobMeta)); + } + context.handle(_anIntEnumMeta, const VerificationResult.success()); + context.handle(_aTextWithConverterMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + TableWithEveryColumnTypeData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return TableWithEveryColumnTypeData( + id: $TableWithEveryColumnTypeTable.$converterid.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!), + aBool: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}a_bool']), + aDateTime: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}a_date_time']), + aText: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}a_text']), + anInt: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}an_int']), + anInt64: attachedDatabase.typeMapping + .read(DriftSqlType.bigInt, data['${effectivePrefix}an_int64']), + aReal: attachedDatabase.typeMapping + .read(DriftSqlType.double, data['${effectivePrefix}a_real']), + aBlob: attachedDatabase.typeMapping + .read(DriftSqlType.blob, data['${effectivePrefix}a_blob']), + anIntEnum: $TableWithEveryColumnTypeTable.$converteranIntEnumn.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}an_int_enum'])), + aTextWithConverter: $TableWithEveryColumnTypeTable + .$converteraTextWithConvertern + .fromSql(attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}insert'])), + ); + } + + @override + $TableWithEveryColumnTypeTable createAlias(String alias) { + return $TableWithEveryColumnTypeTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $converterid = + TypeConverter.extensionType(); + static JsonTypeConverter2 $converteranIntEnum = + const EnumIndexConverter(TodoStatus.values); + static JsonTypeConverter2 $converteranIntEnumn = + JsonTypeConverter2.asNullable($converteranIntEnum); + static JsonTypeConverter2> + $converteraTextWithConverter = const CustomJsonConverter(); + static JsonTypeConverter2?> + $converteraTextWithConvertern = + JsonTypeConverter2.asNullable($converteraTextWithConverter); +} + +class TableWithEveryColumnTypeData extends DataClass + implements Insertable { + final RowId id; + final bool? aBool; + final DateTime? aDateTime; + final String? aText; + final int? anInt; + final BigInt? anInt64; + final double? aReal; + final Uint8List? aBlob; + final TodoStatus? anIntEnum; + final MyCustomObject? aTextWithConverter; + const TableWithEveryColumnTypeData( + {required this.id, + this.aBool, + this.aDateTime, + this.aText, + this.anInt, + this.anInt64, + this.aReal, + this.aBlob, + this.anIntEnum, + this.aTextWithConverter}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + { + map['id'] = + Variable($TableWithEveryColumnTypeTable.$converterid.toSql(id)); + } + if (!nullToAbsent || aBool != null) { + map['a_bool'] = Variable(aBool); + } + if (!nullToAbsent || aDateTime != null) { + map['a_date_time'] = Variable(aDateTime); + } + if (!nullToAbsent || aText != null) { + map['a_text'] = Variable(aText); + } + if (!nullToAbsent || anInt != null) { + map['an_int'] = Variable(anInt); + } + if (!nullToAbsent || anInt64 != null) { + map['an_int64'] = Variable(anInt64); + } + if (!nullToAbsent || aReal != null) { + map['a_real'] = Variable(aReal); + } + if (!nullToAbsent || aBlob != null) { + map['a_blob'] = Variable(aBlob); + } + if (!nullToAbsent || anIntEnum != null) { + map['an_int_enum'] = Variable( + $TableWithEveryColumnTypeTable.$converteranIntEnumn.toSql(anIntEnum)); + } + if (!nullToAbsent || aTextWithConverter != null) { + map['insert'] = Variable($TableWithEveryColumnTypeTable + .$converteraTextWithConvertern + .toSql(aTextWithConverter)); + } + return map; + } + + TableWithEveryColumnTypeCompanion toCompanion(bool nullToAbsent) { + return TableWithEveryColumnTypeCompanion( + id: Value(id), + aBool: + aBool == null && nullToAbsent ? const Value.absent() : Value(aBool), + aDateTime: aDateTime == null && nullToAbsent + ? const Value.absent() + : Value(aDateTime), + aText: + aText == null && nullToAbsent ? const Value.absent() : Value(aText), + anInt: + anInt == null && nullToAbsent ? const Value.absent() : Value(anInt), + anInt64: anInt64 == null && nullToAbsent + ? const Value.absent() + : Value(anInt64), + aReal: + aReal == null && nullToAbsent ? const Value.absent() : Value(aReal), + aBlob: + aBlob == null && nullToAbsent ? const Value.absent() : Value(aBlob), + anIntEnum: anIntEnum == null && nullToAbsent + ? const Value.absent() + : Value(anIntEnum), + aTextWithConverter: aTextWithConverter == null && nullToAbsent + ? const Value.absent() + : Value(aTextWithConverter), + ); + } + + factory TableWithEveryColumnTypeData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return TableWithEveryColumnTypeData( + id: $TableWithEveryColumnTypeTable.$converterid + .fromJson(serializer.fromJson(json['id'])), + aBool: serializer.fromJson(json['aBool']), + aDateTime: serializer.fromJson(json['aDateTime']), + aText: serializer.fromJson(json['aText']), + anInt: serializer.fromJson(json['anInt']), + anInt64: serializer.fromJson(json['anInt64']), + aReal: serializer.fromJson(json['aReal']), + aBlob: serializer.fromJson(json['aBlob']), + anIntEnum: $TableWithEveryColumnTypeTable.$converteranIntEnumn + .fromJson(serializer.fromJson(json['anIntEnum'])), + aTextWithConverter: $TableWithEveryColumnTypeTable + .$converteraTextWithConvertern + .fromJson(serializer + .fromJson?>(json['aTextWithConverter'])), + ); + } + factory TableWithEveryColumnTypeData.fromJsonString(String encodedJson, + {ValueSerializer? serializer}) => + TableWithEveryColumnTypeData.fromJson( + DataClass.parseJson(encodedJson) as Map, + serializer: serializer); + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer + .toJson($TableWithEveryColumnTypeTable.$converterid.toJson(id)), + 'aBool': serializer.toJson(aBool), + 'aDateTime': serializer.toJson(aDateTime), + 'aText': serializer.toJson(aText), + 'anInt': serializer.toJson(anInt), + 'anInt64': serializer.toJson(anInt64), + 'aReal': serializer.toJson(aReal), + 'aBlob': serializer.toJson(aBlob), + 'anIntEnum': serializer.toJson($TableWithEveryColumnTypeTable + .$converteranIntEnumn + .toJson(anIntEnum)), + 'aTextWithConverter': serializer.toJson?>( + $TableWithEveryColumnTypeTable.$converteraTextWithConvertern + .toJson(aTextWithConverter)), + }; + } + + TableWithEveryColumnTypeData copyWith( + {RowId? id, + Value aBool = const Value.absent(), + Value aDateTime = const Value.absent(), + Value aText = const Value.absent(), + Value anInt = const Value.absent(), + Value anInt64 = const Value.absent(), + Value aReal = const Value.absent(), + Value aBlob = const Value.absent(), + Value anIntEnum = const Value.absent(), + Value aTextWithConverter = const Value.absent()}) => + TableWithEveryColumnTypeData( + id: id ?? this.id, + aBool: aBool.present ? aBool.value : this.aBool, + aDateTime: aDateTime.present ? aDateTime.value : this.aDateTime, + aText: aText.present ? aText.value : this.aText, + anInt: anInt.present ? anInt.value : this.anInt, + anInt64: anInt64.present ? anInt64.value : this.anInt64, + aReal: aReal.present ? aReal.value : this.aReal, + aBlob: aBlob.present ? aBlob.value : this.aBlob, + anIntEnum: anIntEnum.present ? anIntEnum.value : this.anIntEnum, + aTextWithConverter: aTextWithConverter.present + ? aTextWithConverter.value + : this.aTextWithConverter, + ); + @override + String toString() { + return (StringBuffer('TableWithEveryColumnTypeData(') + ..write('id: $id, ') + ..write('aBool: $aBool, ') + ..write('aDateTime: $aDateTime, ') + ..write('aText: $aText, ') + ..write('anInt: $anInt, ') + ..write('anInt64: $anInt64, ') + ..write('aReal: $aReal, ') + ..write('aBlob: $aBlob, ') + ..write('anIntEnum: $anIntEnum, ') + ..write('aTextWithConverter: $aTextWithConverter') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, aBool, aDateTime, aText, anInt, anInt64, + aReal, $driftBlobEquality.hash(aBlob), anIntEnum, aTextWithConverter); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is TableWithEveryColumnTypeData && + other.id == this.id && + other.aBool == this.aBool && + other.aDateTime == this.aDateTime && + other.aText == this.aText && + other.anInt == this.anInt && + other.anInt64 == this.anInt64 && + other.aReal == this.aReal && + $driftBlobEquality.equals(other.aBlob, this.aBlob) && + other.anIntEnum == this.anIntEnum && + other.aTextWithConverter == this.aTextWithConverter); +} + +class TableWithEveryColumnTypeCompanion + extends UpdateCompanion { + final Value id; + final Value aBool; + final Value aDateTime; + final Value aText; + final Value anInt; + final Value anInt64; + final Value aReal; + final Value aBlob; + final Value anIntEnum; + final Value aTextWithConverter; + const TableWithEveryColumnTypeCompanion({ + this.id = const Value.absent(), + this.aBool = const Value.absent(), + this.aDateTime = const Value.absent(), + this.aText = const Value.absent(), + this.anInt = const Value.absent(), + this.anInt64 = const Value.absent(), + this.aReal = const Value.absent(), + this.aBlob = const Value.absent(), + this.anIntEnum = const Value.absent(), + this.aTextWithConverter = const Value.absent(), + }); + TableWithEveryColumnTypeCompanion.insert({ + this.id = const Value.absent(), + this.aBool = const Value.absent(), + this.aDateTime = const Value.absent(), + this.aText = const Value.absent(), + this.anInt = const Value.absent(), + this.anInt64 = const Value.absent(), + this.aReal = const Value.absent(), + this.aBlob = const Value.absent(), + this.anIntEnum = const Value.absent(), + this.aTextWithConverter = const Value.absent(), + }); + static Insertable custom({ + Expression? id, + Expression? aBool, + Expression? aDateTime, + Expression? aText, + Expression? anInt, + Expression? anInt64, + Expression? aReal, + Expression? aBlob, + Expression? anIntEnum, + Expression? aTextWithConverter, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (aBool != null) 'a_bool': aBool, + if (aDateTime != null) 'a_date_time': aDateTime, + if (aText != null) 'a_text': aText, + if (anInt != null) 'an_int': anInt, + if (anInt64 != null) 'an_int64': anInt64, + if (aReal != null) 'a_real': aReal, + if (aBlob != null) 'a_blob': aBlob, + if (anIntEnum != null) 'an_int_enum': anIntEnum, + if (aTextWithConverter != null) 'insert': aTextWithConverter, + }); + } + + TableWithEveryColumnTypeCompanion copyWith( + {Value? id, + Value? aBool, + Value? aDateTime, + Value? aText, + Value? anInt, + Value? anInt64, + Value? aReal, + Value? aBlob, + Value? anIntEnum, + Value? aTextWithConverter}) { + return TableWithEveryColumnTypeCompanion( + id: id ?? this.id, + aBool: aBool ?? this.aBool, + aDateTime: aDateTime ?? this.aDateTime, + aText: aText ?? this.aText, + anInt: anInt ?? this.anInt, + anInt64: anInt64 ?? this.anInt64, + aReal: aReal ?? this.aReal, + aBlob: aBlob ?? this.aBlob, + anIntEnum: anIntEnum ?? this.anIntEnum, + aTextWithConverter: aTextWithConverter ?? this.aTextWithConverter, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable( + $TableWithEveryColumnTypeTable.$converterid.toSql(id.value)); + } + if (aBool.present) { + map['a_bool'] = Variable(aBool.value); + } + if (aDateTime.present) { + map['a_date_time'] = Variable(aDateTime.value); + } + if (aText.present) { + map['a_text'] = Variable(aText.value); + } + if (anInt.present) { + map['an_int'] = Variable(anInt.value); + } + if (anInt64.present) { + map['an_int64'] = Variable(anInt64.value); + } + if (aReal.present) { + map['a_real'] = Variable(aReal.value); + } + if (aBlob.present) { + map['a_blob'] = Variable(aBlob.value); + } + if (anIntEnum.present) { + map['an_int_enum'] = Variable($TableWithEveryColumnTypeTable + .$converteranIntEnumn + .toSql(anIntEnum.value)); + } + if (aTextWithConverter.present) { + map['insert'] = Variable($TableWithEveryColumnTypeTable + .$converteraTextWithConvertern + .toSql(aTextWithConverter.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('TableWithEveryColumnTypeCompanion(') + ..write('id: $id, ') + ..write('aBool: $aBool, ') + ..write('aDateTime: $aDateTime, ') + ..write('aText: $aText, ') + ..write('anInt: $anInt, ') + ..write('anInt64: $anInt64, ') + ..write('aReal: $aReal, ') + ..write('aBlob: $aBlob, ') + ..write('anIntEnum: $anIntEnum, ') + ..write('aTextWithConverter: $aTextWithConverter') + ..write(')')) + .toString(); + } +} + class CategoryTodoCountViewData extends DataClass { final int? categoryId; final String? description; @@ -1946,6 +2404,8 @@ abstract class _$TodoDb extends GeneratedDatabase { late final $TableWithoutPKTable tableWithoutPK = $TableWithoutPKTable(this); late final $PureDefaultsTable pureDefaults = $PureDefaultsTable(this); late final $WithCustomTypeTable withCustomType = $WithCustomTypeTable(this); + late final $TableWithEveryColumnTypeTable tableWithEveryColumnType = + $TableWithEveryColumnTypeTable(this); late final $CategoryTodoCountViewView categoryTodoCountView = $CategoryTodoCountViewView(this); late final $TodoWithCategoryViewView todoWithCategoryView = @@ -1964,8 +2424,6 @@ abstract class _$TodoDb extends GeneratedDatabase { title: row.readNullable('title'), content: row.read('content'), targetDate: row.readNullable('target_date'), - someFloat: row.readNullable('some_float'), - someInt64: row.readNullable('some_int64'), category: row.readNullable('category'), status: NullAwareTypeConverter.wrapFromSql( $TodosTableTable.$converterstatus, @@ -2034,6 +2492,7 @@ abstract class _$TodoDb extends GeneratedDatabase { tableWithoutPK, pureDefaults, withCustomType, + tableWithEveryColumnType, categoryTodoCountView, todoWithCategoryView ]; @@ -2146,8 +2605,6 @@ class $$TodosTableTableFilterComposer ColumnFilters get title => ColumnFilters($table.title); ColumnFilters get content => ColumnFilters($table.content); ColumnFilters get targetDate => ColumnFilters($table.targetDate); - ColumnFilters get someFloat => ColumnFilters($table.someFloat); - ColumnFilters get someInt64 => ColumnFilters($table.someInt64); ColumnFilters get categoryId => ColumnFilters($table.category); ComposableFilter category( ComposableFilter Function($$CategoriesTableFilterComposer f) f) { @@ -2174,8 +2631,6 @@ class $$TodosTableTableOrderingComposer ColumnOrderings get title => ColumnOrderings($table.title); ColumnOrderings get content => ColumnOrderings($table.content); ColumnOrderings get targetDate => ColumnOrderings($table.targetDate); - ColumnOrderings get someFloat => ColumnOrderings($table.someFloat); - ColumnOrderings get someInt64 => ColumnOrderings($table.someInt64); ColumnOrderings get categoryId => ColumnOrderings($table.category); ComposableOrdering category( ComposableOrdering Function($$CategoriesTableOrderingComposer o) o) { @@ -2210,8 +2665,6 @@ typedef $$TodosTableTableInsertCompanionBuilder = TodosTableCompanion Function({ Value title, required String content, Value targetDate, - Value someFloat, - Value someInt64, Value category, Value status, }); @@ -2220,8 +2673,6 @@ typedef $$TodosTableTableUpdateCompanionBuilder = TodosTableCompanion Function({ Value title, Value content, Value targetDate, - Value someFloat, - Value someInt64, Value category, Value status, }); @@ -2248,8 +2699,6 @@ class $$TodosTableTableTableManager extends RootTableManager< Value title = const Value.absent(), Value content = const Value.absent(), Value targetDate = const Value.absent(), - Value someFloat = const Value.absent(), - Value someInt64 = const Value.absent(), Value category = const Value.absent(), Value status = const Value.absent(), }) => @@ -2258,8 +2707,6 @@ class $$TodosTableTableTableManager extends RootTableManager< title: title, content: content, targetDate: targetDate, - someFloat: someFloat, - someInt64: someInt64, category: category, status: status, ), @@ -2268,8 +2715,6 @@ class $$TodosTableTableTableManager extends RootTableManager< Value title = const Value.absent(), required String content, Value targetDate = const Value.absent(), - Value someFloat = const Value.absent(), - Value someInt64 = const Value.absent(), Value category = const Value.absent(), Value status = const Value.absent(), }) => @@ -2278,8 +2723,6 @@ class $$TodosTableTableTableManager extends RootTableManager< title: title, content: content, targetDate: targetDate, - someFloat: someFloat, - someInt64: someInt64, category: category, status: status, ))); @@ -2602,6 +3045,155 @@ class $$WithCustomTypeTableTableManager extends RootTableManager< ))); } +class $$TableWithEveryColumnTypeTableFilterComposer + extends FilterComposer<_$TodoDb, $TableWithEveryColumnTypeTable> { + $$TableWithEveryColumnTypeTableFilterComposer(super.db, super.table); + ColumnFilters get idValue => ColumnFilters($table.id); + ColumnWithTypeConverterFilters get id => + ColumnWithTypeConverterFilters($table.id); + ColumnFilters get aBool => ColumnFilters($table.aBool); + ColumnFilters get aDateTime => ColumnFilters($table.aDateTime); + ColumnFilters get aText => ColumnFilters($table.aText); + ColumnFilters get anInt => ColumnFilters($table.anInt); + ColumnFilters get anInt64 => ColumnFilters($table.anInt64); + ColumnFilters get aReal => ColumnFilters($table.aReal); + ColumnFilters get aBlob => ColumnFilters($table.aBlob); + ColumnFilters get anIntEnumValue => ColumnFilters($table.anIntEnum); + ColumnWithTypeConverterFilters get anIntEnum => + ColumnWithTypeConverterFilters($table.anIntEnum); + ColumnFilters get aTextWithConverterValue => + ColumnFilters($table.aTextWithConverter); + ColumnWithTypeConverterFilters + get aTextWithConverter => + ColumnWithTypeConverterFilters($table.aTextWithConverter); +} + +class $$TableWithEveryColumnTypeTableOrderingComposer + extends OrderingComposer<_$TodoDb, $TableWithEveryColumnTypeTable> { + $$TableWithEveryColumnTypeTableOrderingComposer(super.db, super.table); + ColumnOrderings get id => ColumnOrderings($table.id); + ColumnOrderings get aBool => ColumnOrderings($table.aBool); + ColumnOrderings get aDateTime => ColumnOrderings($table.aDateTime); + ColumnOrderings get aText => ColumnOrderings($table.aText); + ColumnOrderings get anInt => ColumnOrderings($table.anInt); + ColumnOrderings get anInt64 => ColumnOrderings($table.anInt64); + ColumnOrderings get aReal => ColumnOrderings($table.aReal); + ColumnOrderings get aBlob => ColumnOrderings($table.aBlob); + ColumnOrderings get anIntEnum => ColumnOrderings($table.anIntEnum); + ColumnOrderings get aTextWithConverter => + ColumnOrderings($table.aTextWithConverter); +} + +class $$TableWithEveryColumnTypeTableProcessedTableManager + extends ProcessedTableManager< + _$TodoDb, + $TableWithEveryColumnTypeTable, + TableWithEveryColumnTypeData, + $$TableWithEveryColumnTypeTableFilterComposer, + $$TableWithEveryColumnTypeTableOrderingComposer, + $$TableWithEveryColumnTypeTableProcessedTableManager, + $$TableWithEveryColumnTypeTableInsertCompanionBuilder, + $$TableWithEveryColumnTypeTableUpdateCompanionBuilder> { + const $$TableWithEveryColumnTypeTableProcessedTableManager(super.$state); +} + +typedef $$TableWithEveryColumnTypeTableInsertCompanionBuilder + = TableWithEveryColumnTypeCompanion Function({ + Value id, + Value aBool, + Value aDateTime, + Value aText, + Value anInt, + Value anInt64, + Value aReal, + Value aBlob, + Value anIntEnum, + Value aTextWithConverter, +}); +typedef $$TableWithEveryColumnTypeTableUpdateCompanionBuilder + = TableWithEveryColumnTypeCompanion Function({ + Value id, + Value aBool, + Value aDateTime, + Value aText, + Value anInt, + Value anInt64, + Value aReal, + Value aBlob, + Value anIntEnum, + Value aTextWithConverter, +}); + +class $$TableWithEveryColumnTypeTableTableManager extends RootTableManager< + _$TodoDb, + $TableWithEveryColumnTypeTable, + TableWithEveryColumnTypeData, + $$TableWithEveryColumnTypeTableFilterComposer, + $$TableWithEveryColumnTypeTableOrderingComposer, + $$TableWithEveryColumnTypeTableProcessedTableManager, + $$TableWithEveryColumnTypeTableInsertCompanionBuilder, + $$TableWithEveryColumnTypeTableUpdateCompanionBuilder> { + $$TableWithEveryColumnTypeTableTableManager( + _$TodoDb db, $TableWithEveryColumnTypeTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$TableWithEveryColumnTypeTableFilterComposer(db, table), + orderingComposer: + $$TableWithEveryColumnTypeTableOrderingComposer(db, table), + getChildManagerBuilder: (p0) => + $$TableWithEveryColumnTypeTableProcessedTableManager(p0), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value aBool = const Value.absent(), + Value aDateTime = const Value.absent(), + Value aText = const Value.absent(), + Value anInt = const Value.absent(), + Value anInt64 = const Value.absent(), + Value aReal = const Value.absent(), + Value aBlob = const Value.absent(), + Value anIntEnum = const Value.absent(), + Value aTextWithConverter = const Value.absent(), + }) => + TableWithEveryColumnTypeCompanion( + id: id, + aBool: aBool, + aDateTime: aDateTime, + aText: aText, + anInt: anInt, + anInt64: anInt64, + aReal: aReal, + aBlob: aBlob, + anIntEnum: anIntEnum, + aTextWithConverter: aTextWithConverter, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + Value aBool = const Value.absent(), + Value aDateTime = const Value.absent(), + Value aText = const Value.absent(), + Value anInt = const Value.absent(), + Value anInt64 = const Value.absent(), + Value aReal = const Value.absent(), + Value aBlob = const Value.absent(), + Value anIntEnum = const Value.absent(), + Value aTextWithConverter = const Value.absent(), + }) => + TableWithEveryColumnTypeCompanion.insert( + id: id, + aBool: aBool, + aDateTime: aDateTime, + aText: aText, + anInt: anInt, + anInt64: anInt64, + aReal: aReal, + aBlob: aBlob, + anIntEnum: anIntEnum, + aTextWithConverter: aTextWithConverter, + ))); +} + class _$TodoDbManager { final _$TodoDb _db; _$TodoDbManager(this._db); @@ -2617,6 +3209,9 @@ class _$TodoDbManager { $$PureDefaultsTableTableManager(_db, _db.pureDefaults); $$WithCustomTypeTableTableManager get withCustomType => $$WithCustomTypeTableTableManager(_db, _db.withCustomType); + $$TableWithEveryColumnTypeTableTableManager get tableWithEveryColumnType => + $$TableWithEveryColumnTypeTableTableManager( + _db, _db.tableWithEveryColumnType); } class AllTodosWithCategoryResult extends CustomResultSet { @@ -2624,8 +3219,6 @@ class AllTodosWithCategoryResult extends CustomResultSet { final String? title; final String content; final DateTime? targetDate; - final double? someFloat; - final BigInt? someInt64; final int? category; final TodoStatus? status; final RowId catId; @@ -2636,16 +3229,14 @@ class AllTodosWithCategoryResult extends CustomResultSet { this.title, required this.content, this.targetDate, - this.someFloat, - this.someInt64, this.category, this.status, required this.catId, required this.catDesc, }) : super(row); @override - int get hashCode => Object.hash(id, title, content, targetDate, someFloat, - someInt64, category, status, catId, catDesc); + int get hashCode => Object.hash( + id, title, content, targetDate, category, status, catId, catDesc); @override bool operator ==(Object other) => identical(this, other) || @@ -2654,8 +3245,6 @@ class AllTodosWithCategoryResult extends CustomResultSet { other.title == this.title && other.content == this.content && other.targetDate == this.targetDate && - other.someFloat == this.someFloat && - other.someInt64 == this.someInt64 && other.category == this.category && other.status == this.status && other.catId == this.catId && @@ -2667,8 +3256,6 @@ class AllTodosWithCategoryResult extends CustomResultSet { ..write('title: $title, ') ..write('content: $content, ') ..write('targetDate: $targetDate, ') - ..write('someFloat: $someFloat, ') - ..write('someInt64: $someInt64, ') ..write('category: $category, ') ..write('status: $status, ') ..write('catId: $catId, ') diff --git a/drift/test/manager/manager_filter_tests.dart b/drift/test/manager/manager_filter_tests.dart index 7af64365..925bdb96 100644 --- a/drift/test/manager/manager_filter_tests.dart +++ b/drift/test/manager/manager_filter_tests.dart @@ -23,246 +23,256 @@ void main() { // (o) => o(priority: Value(CategoryPriority.high), description: "Other")); // // School - // await db.managers.todosTable.create((o) => o( - // content: "Get that math homework done", + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: Value("Get that math homework done"), // title: Value("Math Homework"), // category: Value(schoolId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1,seconds: 10))))); - // await db.managers.todosTable.create((o) => o( - // content: "Finish that report", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1,seconds: 10))))); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Finish that report", // title: Value("Report"), // category: Value(workId), - // status: Value(TodoStatus.workInProgress), - // targetDate: Value(DateTime.now().add(Duration(days: 2,seconds: 10))))); - // await db.managers.todosTable.create((o) => o( - // content: "Get that english homework done", + // anIntEnum: Value(TodoStatus.workInProgress), + // aDateTime: Value(DateTime.now().add(Duration(days: 2,seconds: 10))))); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Get that english homework done", // title: Value("English Homework"), // category: Value(schoolId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1,seconds: 15))))); - // await db.managers.todosTable.create((o) => o( - // content: "Finish that Book report", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1,seconds: 15))))); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Finish that Book report", // title: Value("Book Report"), // category: Value(workId), - // status: Value(TodoStatus.done), - // targetDate: Value(DateTime.now().subtract(Duration(days: 2,seconds: 15))))); + // anIntEnum: Value(TodoStatus.done), + // aDateTime: Value(DateTime.now().subtract(Duration(days: 2,seconds: 15))))); // // Work - // await db.managers.todosTable.create((o) => o( - // content: "File those reports", + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "File those reports", // title: Value("File Reports"), // category: Value(workId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 20))));); - // await db.managers.todosTable.create((o) => o( - // content: "Clean the office", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 20))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Clean the office", // title: Value("Clean Office"), // category: Value(workId), - // status: Value(TodoStatus.workInProgress), - // targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 20))));); - // await db.managers.todosTable.create((o) => o( - // content: "Nail that presentation", + // anIntEnum: Value(TodoStatus.workInProgress), + // aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 20))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Nail that presentation", // title: Value("Presentation"), // category: Value(workId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 25))))); - // await db.managers.todosTable.create((o) => o( - // content: "Take a break", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 25))))); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Take a break", // title: Value("Break"), // category: Value(workId), - // status: Value(TodoStatus.done), - // targetDate: Value(DateTime.now().subtract(Duration(days: 2, seconds: 25))))); + // anIntEnum: Value(TodoStatus.done), + // aDateTime: Value(DateTime.now().subtract(Duration(days: 2, seconds: 25))))); // // Work - // await db.managers.todosTable.create((o) => o( - // content: "Take out the trash", + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Take out the trash", // title: Value("Trash"), // category: Value(homeId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 30))));); - // await db.managers.todosTable.create((o) => o( - // content: "Mow the lawn", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 30))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Mow the lawn", // title: Value("Lawn"), // category: Value(homeId), - // status: Value(TodoStatus.workInProgress), - // targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 30))))); - // await db.managers.todosTable.create((o) => o( - // content: "Fix the sink", + // anIntEnum: Value(TodoStatus.workInProgress), + // aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 30))))); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Fix the sink", // title: Value("Sink"), // category: Value(homeId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 35))));); - // await db.managers.todosTable.create((o) => o( - // content: "Paint the walls", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 35))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Paint the walls", // title: Value("Paint"), // category: Value(homeId), - // status: Value(TodoStatus.done), - // targetDate: Value(DateTime.now().subtract(Duration(days: 2, seconds: 35))))); + // anIntEnum: Value(TodoStatus.done), + // aDateTime: Value(DateTime.now().subtract(Duration(days: 2, seconds: 35))))); // // Other - // await db.managers.todosTable.create((o) => o( - // content: "Get groceries", + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Get groceries", // title: Value("Groceries"), // category: Value(otherId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 40))));); - // await db.managers.todosTable.create((o) => o( - // content: "Pick up the kids", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 40))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Pick up the kids", // title: Value("Kids"), // category: Value(otherId), - // status: Value(TodoStatus.workInProgress), - // targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 40))));); - // await db.managers.todosTable.create((o) => o( - // content: "Take the dog for a walk", + // anIntEnum: Value(TodoStatus.workInProgress), + // aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 40))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Take the dog for a walk", // title: Value("Dog"), // category: Value(otherId), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 45))))); + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 45))))); // // Items with no category - // await db.managers.todosTable.create((o) => o( - // content: "Get Whiteboard", + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Get Whiteboard", // title: Value("Whiteboard"), - // status: Value(TodoStatus.open), - // targetDate: Value(DateTime.now().add(Duration(days: 1, seconds: 50))));); - // await db.managers.todosTable.create((o) => o( - // content: "Drink Water", + // anIntEnum: Value(TodoStatus.open), + // aDateTime: Value(DateTime.now().add(Duration(days: 1, seconds: 50))));); + // await db.managers.tableWithEveryColumnType.create((o) => o( + // aText: "Drink Water", // title: Value("Water"), - // status: Value(TodoStatus.workInProgress), - // targetDate: Value(DateTime.now().add(Duration(days: 2, seconds: 50))))); + // anIntEnum: Value(TodoStatus.workInProgress), + // aDateTime: Value(DateTime.now().add(Duration(days: 2, seconds: 50))))); // }); tearDown(() => db.close()); test('manager - query generic', () async { - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(5.0), - targetDate: Value(DateTime.now().add(Duration(days: 1))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - targetDate: Value(DateTime.now().add(Duration(days: 2))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(3.0), - targetDate: Value(DateTime.now().add(Duration(days: 3))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(5.0), + aDateTime: Value(DateTime.now().add(Duration(days: 1))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aDateTime: Value(DateTime.now().add(Duration(days: 2))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(3.0), + aDateTime: Value(DateTime.now().add(Duration(days: 3))))); // Equals expect( - db.managers.todosTable.filter((f) => f.someFloat.equals(5.0)).count(), + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.equals(5.0)) + .count(), completion(1)); - expect(db.managers.todosTable.filter((f) => f.someFloat(3.0)).count(), + expect( + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal(3.0)) + .count(), completion(1)); // In expect( - db.managers.todosTable - .filter((f) => f.someFloat.isIn([3.0, 5.0])) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isIn([3.0, 5.0])) .count(), completion(2)); // Not In expect( - db.managers.todosTable - .filter((f) => f.someFloat.isNotIn([3.0, 5.0])) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isNotIn([3.0, 5.0])) .count(), completion(0)); // Null check - expect(db.managers.todosTable.filter((f) => f.someFloat.isNull()).count(), + expect( + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isNull()) + .count(), completion(1)); expect( - db.managers.todosTable.filter((f) => f.someFloat.isNotNull()).count(), + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isNotNull()) + .count(), completion(2)); }); test('manager - query number', () async { - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(5.0), - targetDate: Value(DateTime.now().add(Duration(days: 1))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - targetDate: Value(DateTime.now().add(Duration(days: 2))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(3.0), - targetDate: Value(DateTime.now().add(Duration(days: 3))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(5.0), + aDateTime: Value(DateTime.now().add(Duration(days: 1))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aDateTime: Value(DateTime.now().add(Duration(days: 2))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(3.0), + aDateTime: Value(DateTime.now().add(Duration(days: 3))))); // More than expect( - db.managers.todosTable - .filter((f) => f.someFloat.isBiggerThan(3.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isBiggerThan(3.0)) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.someFloat.isBiggerOrEqualTo(3.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isBiggerOrEqualTo(3.0)) .count(), completion(2)); // Less than expect( - db.managers.todosTable - .filter((f) => f.someFloat.isSmallerThan(5.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isSmallerThan(5.0)) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.someFloat.isSmallerOrEqualTo(5.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isSmallerOrEqualTo(5.0)) .count(), completion(2)); // Between expect( - db.managers.todosTable - .filter((f) => f.someFloat.isBetween(3.0, 5.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isBetween(3.0, 5.0)) .count(), completion(2)); expect( - db.managers.todosTable - .filter((f) => f.someFloat.isNotBetween(3.0, 5.0)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aReal.isNotBetween(3.0, 5.0)) .count(), completion(0)); }); test('manager - query string', () async { - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), )); - await db.managers.todosTable.create((o) => o( - content: "That homework Done", + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("That homework Done"), )); - await db.managers.todosTable.create((o) => o( - content: "that MATH homework", - status: Value(TodoStatus.open), + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("that MATH homework"), + anIntEnum: Value(TodoStatus.open), )); // StartsWith expect( - db.managers.todosTable - .filter((f) => f.content.startsWith("that")) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.startsWith("that")) .count(), completion(2)); // EndsWith expect( - db.managers.todosTable - .filter((f) => f.content.endsWith("done")) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.endsWith("done")) .count(), completion(2)); // Contains expect( - db.managers.todosTable - .filter((f) => f.content.contains("math")) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.contains("math")) .count(), completion(2)); @@ -271,77 +281,77 @@ void main() { // StartsWith expect( - db.managers.todosTable - .filter((f) => f.content.startsWith("that", caseInsensitive: false)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.startsWith("that", caseInsensitive: false)) .count(), completion(1)); // EndsWith expect( - db.managers.todosTable - .filter((f) => f.content.endsWith("done", caseInsensitive: false)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.endsWith("done", caseInsensitive: false)) .count(), completion(1)); // Contains expect( - db.managers.todosTable - .filter((f) => f.content.contains("math", caseInsensitive: false)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aText.contains("math", caseInsensitive: false)) .count(), completion(1)); }); test('manager - query int64', () async { - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someInt64: Value(BigInt.from(5.0)), - targetDate: Value(DateTime.now().add(Duration(days: 1))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - targetDate: Value(DateTime.now().add(Duration(days: 2))))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someInt64: Value(BigInt.from(3.0)), - targetDate: Value(DateTime.now().add(Duration(days: 3))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + anInt64: Value(BigInt.from(5.0)), + aDateTime: Value(DateTime.now().add(Duration(days: 1))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aDateTime: Value(DateTime.now().add(Duration(days: 2))))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + anInt64: Value(BigInt.from(3.0)), + aDateTime: Value(DateTime.now().add(Duration(days: 3))))); // More than expect( - db.managers.todosTable - .filter((f) => f.someInt64.isBiggerThan(BigInt.from(3.0))) + db.managers.tableWithEveryColumnType + .filter((f) => f.anInt64.isBiggerThan(BigInt.from(3.0))) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.someInt64.isBiggerOrEqualTo(BigInt.from(3.0))) + db.managers.tableWithEveryColumnType + .filter((f) => f.anInt64.isBiggerOrEqualTo(BigInt.from(3.0))) .count(), completion(2)); // Less than expect( - db.managers.todosTable - .filter((f) => f.someInt64.isSmallerThan(BigInt.from(5.0))) + db.managers.tableWithEveryColumnType + .filter((f) => f.anInt64.isSmallerThan(BigInt.from(5.0))) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.someInt64.isSmallerOrEqualTo(BigInt.from(5.0))) + db.managers.tableWithEveryColumnType + .filter((f) => f.anInt64.isSmallerOrEqualTo(BigInt.from(5.0))) .count(), completion(2)); // Between expect( - db.managers.todosTable - .filter((f) => - f.someInt64.isBetween(BigInt.from(3.0), BigInt.from(5.0))) + db.managers.tableWithEveryColumnType + .filter( + (f) => f.anInt64.isBetween(BigInt.from(3.0), BigInt.from(5.0))) .count(), completion(2)); expect( - db.managers.todosTable + db.managers.tableWithEveryColumnType .filter((f) => - f.someInt64.isNotBetween(BigInt.from(3.0), BigInt.from(5.0))) + f.anInt64.isNotBetween(BigInt.from(3.0), BigInt.from(5.0))) .count(), completion(0)); }); @@ -375,95 +385,97 @@ void main() { final day1 = DateTime.now().add(Duration(days: 1)); final day2 = DateTime.now().add(Duration(days: 2)); final day3 = DateTime.now().add(Duration(days: 3)); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(5.0), - targetDate: Value(day1))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - targetDate: Value(day2))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open), - someFloat: Value(3.0), - targetDate: Value(day3))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(5.0), + aDateTime: Value(day1))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aDateTime: Value(day2))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open), + aReal: Value(3.0), + aDateTime: Value(day3))); // More than expect( - db.managers.todosTable - .filter((f) => f.targetDate.isAfter(day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isAfter(day2)) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.targetDate.isAfterOrOn(day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isAfterOrOn(day2)) .count(), completion(2)); // Less than expect( - db.managers.todosTable - .filter((f) => f.targetDate.isBefore(day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isBefore(day2)) .count(), completion(1)); expect( - db.managers.todosTable - .filter((f) => f.targetDate.isBeforeOrOn(day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isBeforeOrOn(day2)) .count(), completion(2)); // Between expect( - db.managers.todosTable - .filter((f) => f.targetDate.isBetween(day1, day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isBetween(day1, day2)) .count(), completion(2)); expect( - db.managers.todosTable - .filter((f) => f.targetDate.isNotBetween(day1, day2)) + db.managers.tableWithEveryColumnType + .filter((f) => f.aDateTime.isNotBetween(day1, day2)) .count(), completion(1)); }); test('manager - query custom column', () async { - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.open))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.workInProgress))); - await db.managers.todosTable.create((o) => o( - content: "Get that math homework done", - status: Value(TodoStatus.done))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.open))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.workInProgress))); + await db.managers.tableWithEveryColumnType.create((o) => o( + aText: Value("Get that math homework done"), + anIntEnum: Value(TodoStatus.done))); // Equals expect( - db.managers.todosTable - .filter((f) => f.status.equals(TodoStatus.open)) + db.managers.tableWithEveryColumnType + .filter((f) => f.anIntEnum.equals(TodoStatus.open)) .count(), completion(2)); expect( - db.managers.todosTable.filter((f) => f.status(TodoStatus.open)).count(), + db.managers.tableWithEveryColumnType + .filter((f) => f.anIntEnum(TodoStatus.open)) + .count(), completion(2)); // In expect( - db.managers.todosTable + db.managers.tableWithEveryColumnType .filter((f) => - f.status.isIn([TodoStatus.open, TodoStatus.workInProgress])) + f.anIntEnum.isIn([TodoStatus.open, TodoStatus.workInProgress])) .count(), completion(3)); // Not In expect( - db.managers.todosTable - .filter((f) => - f.status.isNotIn([TodoStatus.open, TodoStatus.workInProgress])) + db.managers.tableWithEveryColumnType + .filter((f) => f.anIntEnum + .isNotIn([TodoStatus.open, TodoStatus.workInProgress])) .count(), completion(1)); });