message: Implemented compactOnLaunch test

diff:
+import 'dart:io';
+
+import 'package:isar/isar.dart';
+import 'package:test/test.dart';
+
+import 'util/common.dart';
+import 'util/sync_async_helper.dart';
+
+part 'compact_on_launch_test.g.dart';
+
+@Collection()
+class Model {
+ Id id = Isar.autoIncrement;
+
+ List<int> buffer = List.filled(16000, 42);
+
+ @override
+ // ignore: hash_and_equals
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is Model &&
+ runtimeType == other.runtimeType &&
+ id == other.id &&
+ listEquals(buffer, other.buffer);
+
+ @override
+ String toString() {
+ return 'Model{id: $id}';
+ }
+}
+
+void main() {
+ group('Compact on launch', () {
+ late Isar isar;
+ late File file;
+
+ setUp(() async {
+ isar = await openTempIsar([ModelSchema]);
+ file = File(isar.path!);
+
+ await isar.tWriteTxn(
+ () => isar.models.tPutAll(List.filled(100, Model())),
+ );
+ });
+
+ tearDown(() => isar.close(deleteFromDisk: true));
+
+ isarTestVm('No compact on launch', () async {
+ await isar.close();
+ final size1 = file.lengthSync();
+
+ isar = await openTempIsar([ModelSchema], name: isar.name);
+ await isar.tWriteTxn(() => isar.models.where().limit(50).tDeleteAll());
+ await isar.close();
+
+ final size2 = file.lengthSync();
+
+ isar = await openTempIsar([ModelSchema], name: isar.name);
+
+ expect(size1, size2);
+ });
+
+ isarTestVm('minFileSize', () async {
+ await isar.close();
+ final size1 = file.lengthSync();
+
+ isar = await openTempIsar([ModelSchema], name: isar.name);
+ await isar.tWriteTxn(() => isar.models.where().limit(50).tDeleteAll());
+ await isar.close();
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: CompactCondition(minFileSize: size1 * 2),
+ );
+ await isar.close();
+ final size2 = file.lengthSync();
+ expect(size1, size2);
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: CompactCondition(minFileSize: size1 ~/ 2),
+ );
+ final size3 = file.lengthSync();
+ expect(size3, lessThan(size2));
+ });
+
+ isarTestVm('minBytes', () async {
+ await isar.close();
+ final size1 = file.lengthSync();
+
+ isar = await openTempIsar([ModelSchema], name: isar.name);
+ await isar.tWriteTxn(() => isar.models.where().limit(10).tDeleteAll());
+ await isar.close();
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: CompactCondition(minBytes: size1 ~/ 2),
+ );
+ await isar.close();
+ final size2 = file.lengthSync();
+ expect(size1, size2);
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: CompactCondition(minBytes: size1 ~/ 2),
+ );
+ await isar.tWriteTxn(() => isar.models.where().limit(80).tDeleteAll());
+ await isar.close();
+ final size3 = file.lengthSync();
+ expect(size3, size2);
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: CompactCondition(minBytes: size1 ~/ 2),
+ );
+ final size4 = file.lengthSync();
+ expect(size4, lessThan(size3));
+ });
+
+ isarTestVm('minRatio', () async {
+ await isar.close();
+ final size1 = file.lengthSync();
+
+ isar = await openTempIsar([ModelSchema], name: isar.name);
+ await isar.tWriteTxn(() => isar.models.where().limit(10).tDeleteAll());
+ await isar.close();
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: const CompactCondition(minRatio: 2),
+ );
+ await isar.close();
+ final size2 = file.lengthSync();
+ expect(size1, size2);
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: const CompactCondition(minRatio: 2),
+ );
+ await isar.tWriteTxn(() => isar.models.where().limit(80).tDeleteAll());
+ await isar.close();
+ final size3 = file.lengthSync();
+ expect(size3, size2);
+
+ isar = await openTempIsar(
+ [ModelSchema],
+ name: isar.name,
+ compactOnLaunch: const CompactCondition(minRatio: 2),
+ );
+ final size4 = file.lengthSync();
+ expect(size4, lessThan(size3));
+ });
+ });
+}

diff:
@@ -114,6 +114,7 @@ String? testTempPath;
Future<Isar> openTempIsar(
List<CollectionSchema<dynamic>> schemas, {
String? name,
+ CompactCondition? compactOnLaunch,
}) async {
await _prepareTest();
if (!kIsWeb && testTempPath == null) {
@@ -126,6 +127,7 @@ Future<Isar> openTempIsar(
schemas: schemas,
name: name ?? getRandomName(),
directory: kIsWeb ? '' : testTempPath!,
+ compactOnLaunch: compactOnLaunch,
);
await isar.verify();

diff:
@@ -12,6 +12,7 @@ Future<Isar> tOpen({
String? directory,
String name = Isar.defaultName,
bool relaxedDurability = true,
+ CompactCondition? compactOnLaunch,
}) {
if (syncTest) {
final isar = Isar.openSync(
@@ -19,6 +20,7 @@ Future<Isar> tOpen({
directory: directory,
name: name,
relaxedDurability: relaxedDurability,
+ compactOnLaunch: compactOnLaunch,
inspector: false,
);
return SynchronousFuture(isar);
@@ -28,6 +30,7 @@ Future<Isar> tOpen({
directory: directory,
name: name,
relaxedDurability: relaxedDurability,
+ compactOnLaunch: compactOnLaunch,
inspector: false,
);
}

original_message: Implemented compactOnLaunch test


message: Started filter embedded test

change_type: ADD

diff:
+// ignore_for_file: hash_and_equals
+
+import 'package:isar/isar.dart';
+import 'package:test/test.dart';
+
+import '../util/common.dart';
+import '../util/matchers.dart';
+import '../util/sync_async_helper.dart';
+
+part 'filter_embedded_list_test.g.dart';
+
+@collection
+class Model {
+ Model({
+ required this.embeddedAs,
+ required this.embeddedBs,
+ });
+
+ Id id = Isar.autoIncrement;
+
+ List<EmbeddedA> embeddedAs;
+
+ List<EmbeddedB?>? embeddedBs;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is Model &&
+ runtimeType == other.runtimeType &&
+ id == other.id &&
+ listEquals(embeddedAs, other.embeddedAs) &&
+ listEquals(embeddedBs, other.embeddedBs);
+
+ @override
+ String toString() {
+ return 'Model{id: $id, embeddedAs: $embeddedAs, embeddedBs: $embeddedBs}';
+ }
+}
+
+@embedded
+class EmbeddedA {
+ EmbeddedA({
+ this.name = '',
+ this.embeddedBs = const [],
+ });
+
+ String name;
+
+ final List<EmbeddedB?>? embeddedBs;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is EmbeddedA &&
+ runtimeType == other.runtimeType &&
+ name == other.name &&
+ listEquals(embeddedBs, other.embeddedBs);
+
+ @override
+ String toString() {
+ return 'EmbeddedA{name: $name, embeddedBs: $embeddedBs}';
+ }
+}
+
+@embedded
+class EmbeddedB {
+ EmbeddedB({
+ this.name = '',
+ });
+
+ String name;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is EmbeddedB &&
+ runtimeType == other.runtimeType &&
+ name == other.name;
+
+ @override
+ String toString() {
+ return 'EmbeddedB{name: $name}';
+ }
+}
+
+void main() {
+ group('Filter embedded list', () {
+ late Isar isar;
+
+ late Model obj1;
+ late Model obj2;
+ late Model obj3;
+ late Model obj4;
+ late Model obj5;
+ late Model obj6;
+
+ setUp(() async {
+ isar = await openTempIsar([ModelSchema]);
+
+ obj1 = Model(
+ embeddedAs: [
+ EmbeddedA(
+ name: 'embedded a1 - 1',
+ embeddedBs: null,
+ ),
+ EmbeddedA(
+ name: 'embedded a1 - 2',
+ embeddedBs: [null, null],
+ ),
+ EmbeddedA(
+ name: 'embedded a1 - 3',
+ embeddedBs: [
+ EmbeddedB(
+ name: 'embedded a1 b1 - 1',
+ ),
+ EmbeddedB(
+ name: 'embedded a1 b1 - 2',
+ ),
+ EmbeddedB(
+ name: 'embedded a1 b1 - 3',
+ ),
+ ],
+ ),
+ ],
+ embeddedBs: [
+ EmbeddedB(name: 'embedded b1 - 1'),
+ EmbeddedB(name: 'embedded b1 - 2'),
+ EmbeddedB(name: 'embedded b1 - 3'),
+ ],
+ );
+ obj2 = Model(
+ embeddedAs: [
+ EmbeddedA(
+ name: 'embedded a2 - 1',
+ embeddedBs: null,
+ ),
+ ],
+ embeddedBs: [null],
+ );
+ obj3 = Model(
+ embeddedAs: [
+ EmbeddedA(
+ name: 'embedded a3 - 1',
+ embeddedBs: [
+ null,
+ EmbeddedB(name: 'embedded a3 b3 - 1'),
+ ],
+ ),
+ ],
+ embeddedBs: null,
+ );
+ obj4 = Model(
+ embeddedAs: [],
+ embeddedBs: [],
+ );
+ obj5 = Model(
+ embeddedAs: [
+ EmbeddedA(
+ name: 'embedded a5 - 1',
+ embeddedBs: [
+ EmbeddedB(name: 'embedded a5 b5 - 1'),
+ EmbeddedB(name: 'embedded a5 b5 - 2'),
+ EmbeddedB(name: 'embedded a5 b5 - 3'),
+ EmbeddedB(name: 'embedded a5 b5 - 4'),
+ EmbeddedB(name: 'embedded a5 b5 - 5'),
+ ],
+ ),
+ ],
+ embeddedBs: [
+ EmbeddedB(name: 'embedded b5 - 1'),
+ EmbeddedB(name: 'embedded b5 - 2'),
+ EmbeddedB(name: 'embedded b5 - 3'),
+ EmbeddedB(name: 'embedded b5 - 4'),
+ EmbeddedB(name: 'embedded b5 - 5'),
+ ],
+ );
+ obj6 = Model(
+ embeddedAs: [
+ EmbeddedA(
+ name: 'embedded a6 - 1',
+ embeddedBs: [
+ EmbeddedB(name: 'embedded a6 b6 - 1'),
+ null,
+ null,
+ null,
+ ],
+ ),
+ ],
+ embeddedBs: [
+ null,
+ EmbeddedB(name: 'embedded b6 - 1'),
+ null,
+ ],
+ );
+
+ await isar.tWriteTxn(
+ () => isar.models.tPutAll([
+ obj1,
+ obj2,
+ obj3,
+ obj4,
+ obj5,
+ obj6,
+ ]),
+ );
+ });
+
+ isarTest('.embeddedIsNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBsIsNull(),
+ [obj3],
+ );
+ });
+
+ isarTest('.embeddedIsNotNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBsIsNotNull(),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ });
+
+ isarTest('.embeddedLengthEqualTo()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthEqualTo(0),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthEqualTo(1),
+ [obj2, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthEqualTo(3),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthEqualTo(4),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(0),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(1),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(2),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(3),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(4),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(5),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthEqualTo(6),
+ [],
+ );
+ });
+
+ isarTest('.embeddedLengthGreaterThan()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthGreaterThan(0),
+ [obj1, obj2, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthGreaterThan(1),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthGreaterThan(2),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthGreaterThan(3, include: true),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthGreaterThan(3),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(0),
+ [obj1, obj2, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(1),
+ [obj1, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(2),
+ [obj1, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(3),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(4),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(5, include: true),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthGreaterThan(5),
+ [],
+ );
+ });
+
+ isarTest('.embeddedLengthLessThanThan()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(0),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(1),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(2),
+ [obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(3),
+ [obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(3),
+ [obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthLessThan(3, include: true),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(0),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(1),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(2),
+ [obj2, obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(3),
+ [obj2, obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(4),
+ [obj1, obj2, obj4, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(5),
+ [obj1, obj2, obj4, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthLessThan(5, include: true),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ });
+
+ isarTest('.embeddedLengthBetweenThan()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthBetween(1, 3),
+ [obj1, obj2, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthBetween(3, 4),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsLengthBetween(10, 12),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthBetween(1, 3),
+ [obj1, obj2, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthBetween(3, 4),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsLengthBetween(10, 12),
+ [],
+ );
+ });
+
+ isarTest('.embeddedIsEmpty()', () async {});
+ isarTest('.embeddedIsNotEmpty()', () async {});
+
+ // FIXME: IsarError: Unsupported type for condition
+ isarTest('.embeddedElementEqualTo()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj1.embeddedAs[0]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj1.embeddedAs[1]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj1.embeddedAs[2]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj2.embeddedAs[0]),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj3.embeddedAs[0]),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj5.embeddedAs[0]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElementEqualTo(obj6.embeddedAs[0]),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElementEqualTo(EmbeddedA(name: 'non existing')),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj1.embeddedBs![0]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj1.embeddedBs![1]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj1.embeddedBs![2]),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj5.embeddedBs![0]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj5.embeddedBs![1]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj5.embeddedBs![2]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj5.embeddedBs![3]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj5.embeddedBs![4]),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementEqualTo(obj6.embeddedBs![1]),
+ [obj6],
+ );
+ });
+
+ // FIXME: IsarError: IllegalArg: Property does not support this filter..
+ isarTest('.embeddedElementIsNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementIsNull(),
+ [obj2, obj6],
+ );
+ });
+
+ // FIXME: IsarError: IllegalArg: Property does not support this filter..
+ isarTest('.embeddedElementIsNotNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBsElementIsNotNull(),
+ [obj1, obj5, obj6],
+ );
+ });
+
+ isarTest('.embeddedElement()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameStartsWith('embedded')),
+ [obj1, obj2, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a1 - 1')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a1 - 2')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a1 - 3')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a2 - 1')),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a3 - 1')),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a5 - 1')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('embedded a6 - 1')),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.nameEqualTo('non existing')),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameStartsWith('embedded')),
+ [obj1, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b1 - 1')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b1 - 2')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b1 - 3')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b5 - 1')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b5 - 2')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b5 - 3')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b5 - 4')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b5 - 5')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('embedded b6 - 1')),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedBsElement((q) => q.nameEqualTo('non existing')),
+ [],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedIsNull()', () async {});
+ isarTest('.embeddedElement() then .embeddedIsNotNull()', () async {});
+ isarTest('.embeddedElement() then .embeddedLengthEqualTo()', () async {});
+ isarTest('.embeddedElement() then .embeddedLengthLessThan()', () async {});
+ isarTest(
+ '.embeddedElement() then .embeddedLengthGreaterThan()', () async {});
+ isarTest('.embeddedElement() then .embeddedLengthBetween()', () async {});
+ isarTest('.embeddedElement() then .embeddedLengthIsEmpty()', () async {});
+ isarTest(
+ '.embeddedElement() then .embeddedLengthIsNotEmpty()', () async {});
+ isarTest('.embeddedElement() then .embeddedElementIsNull()', () async {});
+ isarTest(
+ '.embeddedElement() then .embeddedElementIsNotNull()', () async {});
+ isarTest('.embeddedElement() then .embeddedElement()', () async {});
+ isarTest('.embeddedElement() then .embeddedElement()', () async {});
+
+ // FIXME: IsarError: Unsupported type for condition
+ isarTest('.embeddedElement() then .embeddedElementEqualTo()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj1.embeddedAs[2].embeddedBs![0],
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj1.embeddedAs[2].embeddedBs![1],
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj1.embeddedAs[2].embeddedBs![2],
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj3.embeddedAs[0].embeddedBs![1],
+ ),
+ ),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![0],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![1],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![2],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![3],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![4],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj5.embeddedAs[0].embeddedBs![5],
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ obj6.embeddedAs[0].embeddedBs![0],
+ ),
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElementEqualTo(
+ EmbeddedB(name: 'non existing'),
+ ),
+ ),
+ [],
+ );
+ });
+ });
+}

diff:
+// ignore_for_file: hash_and_equals
+
+import 'package:isar/isar.dart';
+import 'package:test/test.dart';
+
+import '../util/common.dart';
+import '../util/matchers.dart';
+import '../util/sync_async_helper.dart';
+
+part 'filter_embedded_test.g.dart';
+
+@collection
+class Model {
+ Model({
+ required this.embeddedA,
+ required this.embeddedB,
+ });
+
+ Id id = Isar.autoIncrement;
+
+ // FIXME: Generator doesn't prevent us from indexing this field, but crashes
+ // at runtime (...objects cannot be indexed)
+ // @Index()
+ EmbeddedModelA embeddedA;
+
+ EmbeddedModelB? embeddedB;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is Model &&
+ runtimeType == other.runtimeType &&
+ id == other.id &&
+ embeddedA == other.embeddedA &&
+ embeddedB == other.embeddedB;
+
+ @override
+ String toString() {
+ return '''Model{id: $id, embeddedA: $embeddedA, embeddedB: $embeddedB}''';
+ }
+}
+
+@embedded
+class EmbeddedModelA {
+ const EmbeddedModelA({
+ this.name = '',
+ this.embeddedB = const EmbeddedModelB(),
+ });
+
+ final String name;
+
+ final EmbeddedModelB? embeddedB;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is EmbeddedModelA &&
+ runtimeType == other.runtimeType &&
+ name == other.name &&
+ embeddedB == other.embeddedB;
+
+ @override
+ String toString() {
+ return 'EmbeddedModelA{name: $name, embeddedB: $embeddedB}';
+ }
+}
+
+@embedded
+class EmbeddedModelB {
+ const EmbeddedModelB({
+ this.name = '',
+ });
+
+ final String name;
+
+ @override
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is EmbeddedModelB &&
+ runtimeType == other.runtimeType &&
+ name == other.name;
+
+ @override
+ String toString() {
+ return 'EmbeddedModelB{name: $name}';
+ }
+}
+
+void main() {
+ group('Filter embedded', () {
+ late Isar isar;
+
+ late Model obj1;
+ late Model obj2;
+ late Model obj3;
+ late Model obj4;
+ late Model obj5;
+ late Model obj6;
+
+ setUp(() async {
+ isar = await openTempIsar([ModelSchema]);
+
+ obj1 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a1',
+ embeddedB: EmbeddedModelB(name: 'embedded a1 b1'),
+ ),
+ embeddedB: const EmbeddedModelB(name: 'embedded b1'),
+ );
+ obj2 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a2',
+ embeddedB: EmbeddedModelB(name: 'embedded a2 b2'),
+ ),
+ embeddedB: null,
+ );
+ obj3 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a3',
+ embeddedB: null,
+ ),
+ embeddedB: const EmbeddedModelB(name: 'embedded b3'),
+ );
+ obj4 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a4',
+ embeddedB: EmbeddedModelB(name: 'embedded a4 b4'),
+ ),
+ embeddedB: const EmbeddedModelB(name: 'embedded b4'),
+ );
+ obj5 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a5',
+ embeddedB: null,
+ ),
+ embeddedB: const EmbeddedModelB(name: 'embedded b5'),
+ );
+ obj6 = Model(
+ embeddedA: const EmbeddedModelA(
+ name: 'embedded a6',
+ embeddedB: EmbeddedModelB(name: 'embedded a6 b6'),
+ ),
+ embeddedB: null,
+ );
+
+ await isar.tWriteTxn(
+ () => isar.models.tPutAll([
+ obj1,
+ obj2,
+ obj3,
+ obj4,
+ obj5,
+ obj6,
+ ]),
+ );
+ });
+
+ // FIXME: IsarError: Unsupported type for condition
+ isarTest('.equalTo()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj1.embeddedA),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj2.embeddedA),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj3.embeddedA),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj4.embeddedA),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj5.embeddedA),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(obj6.embeddedA),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAEqualTo(
+ const EmbeddedModelA(
+ name: 'non existing',
+ ),
+ ),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBEqualTo(obj1.embeddedB),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBEqualTo(obj3.embeddedB),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBEqualTo(obj4.embeddedB),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBEqualTo(obj5.embeddedB),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedBEqualTo(
+ const EmbeddedModelB(
+ name: 'non existing',
+ ),
+ ),
+ [],
+ );
+ });
+
+ isarTest('.embedded()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameStartsWith('embedded')),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a1')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a2')),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a3')),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a4')),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a5')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded a6')),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('non existing')),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.nameEqualTo('embedded b1')),
+ [],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameStartsWith('embedded')),
+ [obj1, obj3, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b1')),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b2')),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b3')),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b4')),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b5')),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded b6')),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('non existing')),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedB((q) => q.nameEqualTo('embedded a1')),
+ [],
+ );
+ });
+
+ isarTest('.embeddedIsNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBIsNull(),
+ [obj2, obj6],
+ );
+ });
+
+ isarTest('.embeddedIsNotNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedBIsNotNull(),
+ [obj1, obj3, obj4, obj5],
+ );
+ });
+
+ // FIXME: IsarError: Unsupported type for condition
+ isarTest('.embedded() then .embeddedEqualTo()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj1.embeddedA.embeddedB)),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj2.embeddedA.embeddedB)),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj3.embeddedA.embeddedB)),
+ [obj3, obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj4.embeddedA.embeddedB)),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj5.embeddedA.embeddedB)),
+ [obj3, obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedA((q) => q.embeddedBEqualTo(obj6.embeddedA.embeddedB)),
+ [obj6],
+ );
+ });
+
+ // FIXME(severe): panic
+ // Shell: thread 'isarworker' panicked at 'range start index 6579554 out of
+ // range for slice of length 11', library/core/src/slice/index.rs:52:5
+ isarTest('.embedded() then .embedded()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameStartsWith('embedded'),
+ ),
+ ),
+ [obj1, obj2, obj4, obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a1 b1'),
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a2 b2'),
+ ),
+ ),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a3 b3'),
+ ),
+ ),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a4 b4'),
+ ),
+ ),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a5 b5'),
+ ),
+ ),
+ [],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('embedded a6 b6'),
+ ),
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedA(
+ (q) => q.embeddedB(
+ (q) => q.nameEqualTo('non existing'),
+ ),
+ ),
+ [],
+ );
+ });
+
+ isarTest('.embedded() then .embeddedIsNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.embeddedBIsNull()),
+ [obj3, obj5],
+ );
+ });
+
+ isarTest('.embedded() then .embeddedIsNotNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedA((q) => q.embeddedBIsNotNull()),
+ [obj1, obj2, obj4, obj6],
+ );
+ });
+ });
+}

license: Apache License 2.0

repo: isar/isar

original_message: Started filter embedded test


message: Finished implementing embedded filter

change_type: MODIFY

old_path: .gitignore

new_path: .gitignore

diff:
*.log
.DS_Store
.vscode/
+.idea
# Dart related
.dart_tool/

diff:
@@ -194,14 +194,7 @@ void main() {
);
await isar.tWriteTxn(
- () => isar.models.tPutAll([
- obj1,
- obj2,
- obj3,
- obj4,
- obj5,
- obj6,
- ]),
+ () => isar.models.tPutAll([obj1, obj2, obj3, obj4, obj5, obj6]),
);
});
@@ -403,8 +396,29 @@ void main() {
);
});
- isarTest('.embeddedIsEmpty()', () async {});
- isarTest('.embeddedIsNotEmpty()', () async {});
+ isarTest('.embeddedIsEmpty()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsIsEmpty(),
+ [obj4],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsIsEmpty(),
+ [obj4],
+ );
+ });
+
+ isarTest('.embeddedIsNotEmpty()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsIsNotEmpty(),
+ [obj1, obj2, obj3, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedBsIsNotEmpty(),
+ [obj1, obj2, obj5, obj6],
+ );
+ });
// FIXME: IsarError: Unsupported type for condition
isarTest('.embeddedElementEqualTo()', () async {
@@ -621,21 +635,209 @@ void main() {
);
});
- isarTest('.embeddedElement() then .embeddedIsNull()', () async {});
- isarTest('.embeddedElement() then .embeddedIsNotNull()', () async {});
- isarTest('.embeddedElement() then .embeddedLengthEqualTo()', () async {});
- isarTest('.embeddedElement() then .embeddedLengthLessThan()', () async {});
- isarTest(
- '.embeddedElement() then .embeddedLengthGreaterThan()', () async {});
- isarTest('.embeddedElement() then .embeddedLengthBetween()', () async {});
- isarTest('.embeddedElement() then .embeddedLengthIsEmpty()', () async {});
- isarTest(
- '.embeddedElement() then .embeddedLengthIsNotEmpty()', () async {});
- isarTest('.embeddedElement() then .embeddedElementIsNull()', () async {});
- isarTest(
- '.embeddedElement() then .embeddedElementIsNotNull()', () async {});
- isarTest('.embeddedElement() then .embeddedElement()', () async {});
- isarTest('.embeddedElement() then .embeddedElement()', () async {});
+ isarTest('.embeddedElement() then .embeddedIsNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement((q) => q.embeddedBsIsNull()),
+ [obj1, obj2],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedIsNotNull()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement((q) => q.embeddedBsIsNotNull()),
+ [obj1, obj3, obj5, obj6],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedLengthEqualTo()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(0)),
+ [],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(1)),
+ [],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(2)),
+ [obj1, obj3],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(3)),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(4)),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(5)),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthEqualTo(6)),
+ [],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedLengthLessThan()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(0)),
+ [],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(1)),
+ [],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(2)),
+ [],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(3)),
+ [obj1, obj3],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(4)),
+ [obj1, obj3],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(5)),
+ [obj1, obj3, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(6)),
+ [obj1, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthLessThan(7)),
+ [obj1, obj3, obj5, obj6],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedLengthGreaterThan()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(0)),
+ [obj1, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(1)),
+ [obj1, obj3, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(2)),
+ [obj1, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(3)),
+ [obj5, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(4)),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthGreaterThan(5)),
+ [],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedLengthBetween()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthBetween(2, 4)),
+ [obj1, obj3, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthBetween(3, 4)),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsLengthBetween(5, 42)),
+ [obj5],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedIsEmpty()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement((q) => q.embeddedBsIsEmpty()),
+ [],
+ );
+ });
+
+ isarTest('.embeddedElement() then .embeddedIsNotEmpty()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement((q) => q.embeddedBsIsNotEmpty()),
+ [obj1, obj3, obj5, obj6],
+ );
+ });
+
+ // FIXME: IsarError: IllegalArg: Property does not support this filter..
+ isarTest('.embeddedElement() then .embeddedElementIsNull()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsElementIsNull()),
+ [obj1, obj3, obj6],
+ );
+ });
+
+ // FIXME: IsarError: IllegalArg: Property does not support this filter..
+ isarTest('.embeddedElement() then .embeddedElementIsNotNull()', () async {
+ await qEqualSet(
+ isar.models
+ .filter()
+ .embeddedAsElement((q) => q.embeddedBsElementIsNotNull()),
+ [obj1, obj3, obj5, obj6],
+ );
+ });
// FIXME: IsarError: Unsupported type for condition
isarTest('.embeddedElement() then .embeddedElementEqualTo()', () async {
@@ -663,6 +865,7 @@ void main() {
),
[obj1],
);
+
await qEqualSet(
isar.models.filter().embeddedAsElement(
(q) => q.embeddedBsElementEqualTo(
@@ -671,6 +874,7 @@ void main() {
),
[obj3],
);
+
await qEqualSet(
isar.models.filter().embeddedAsElement(
(q) => q.embeddedBsElementEqualTo(
@@ -711,26 +915,127 @@ void main() {
),
[obj5],
);
+
await qEqualSet(
isar.models.filter().embeddedAsElement(
(q) => q.embeddedBsElementEqualTo(
- obj5.embeddedAs[0].embeddedBs![5],
+ obj6.embeddedAs[0].embeddedBs![0],
),
),
- [obj5],
+ [obj6],
);
+
await qEqualSet(
isar.models.filter().embeddedAsElement(
(q) => q.embeddedBsElementEqualTo(
- obj6.embeddedAs[0].embeddedBs![0],
+ EmbeddedB(name: 'non existing'),
+ ),
+ ),
+ [],
+ );
+ });
+
+ // FIXME(severe): panic
+ // Shell: thread 'isarworker' panicked at 'range end index 6450588 out of
+ // range for slice of length 26', library/core/src/slice/index.rs:73:5
+ isarTest('.embeddedElement() then .embeddedElement()', () async {
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameStartsWith('embedded'),
+ ),
+ ),
+ [obj1, obj3, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a1 b1 - 1'),
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a1 b1 - 2'),
+ ),
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a1 b1 - 3'),
+ ),
+ ),
+ [obj1],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a3 b3 - 1'),
+ ),
+ ),
+ [obj3],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a5 b5 - 1'),
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a5 b5 - 2'),
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a5 b5 - 3'),
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a5 b5 - 4'),
+ ),
+ ),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a5 b5 - 5'),
+ ),
+ ),
+ [obj5],
+ );
+
+ await qEqualSet(
+ isar.models.filter().embeddedAsElement(
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('embedded a6 b6 - 1'),
),
),
[obj6],
);
+
await qEqualSet(
isar.models.filter().embeddedAsElement(
- (q) => q.embeddedBsElementEqualTo(
- EmbeddedB(name: 'non existing'),
+ (q) => q.embeddedBsElement(
+ (q) => q.nameEqualTo('non existing'),
),
),
[],

diff:
@@ -144,14 +144,7 @@ void main() {
);
await isar.tWriteTxn(
- () => isar.models.tPutAll([
- obj1,
- obj2,
- obj3,
- obj4,
- obj5,
- obj6,
- ]),
+ () => isar.models.tPutAll([obj1, obj2, obj3, obj4, obj5, obj6]),
);
});
@@ -182,11 +175,9 @@ void main() {
[obj6],
);
await qEqualSet(
- isar.models.filter().embeddedAEqualTo(
- const EmbeddedModelA(
- name: 'non existing',
- ),
- ),
+ isar.models
+ .filter()
+ .embeddedAEqualTo(const EmbeddedModelA(name: 'non existing')),
[],
);
@@ -207,11 +198,9 @@ void main() {
[obj5],
);
await qEqualSet(
- isar.models.filter().embeddedBEqualTo(
- const EmbeddedModelB(
- name: 'non existing',
- ),
- ),
+ isar.models
+ .filter()
+ .embeddedBEqualTo(const EmbeddedModelB(name: 'non existing')),
[],
);
});

original_message: Finished implementing embedded filter


message: Added query isEmpty / isNotEmpty tests

diff:
+import 'package:isar/isar.dart';
+import 'package:test/test.dart';
+
+import '../util/common.dart';
+import '../util/sync_async_helper.dart';
+
+part 'is_empty_is_not_empty_test.g.dart';
+
+@collection
+class Model {
+ Model(this.value);
+
+ Id id = Isar.autoIncrement;
+
+ String? value;
+}
+
+void main() {
+ group('Query isEmpty / isNotEmpty', () {
+ late Isar isar;
+
+ setUp(() async {
+ isar = await openTempIsar([ModelSchema]);
+
+ await isar.tWriteTxn(
+ () => isar.models.tPutAll(List.generate(100, (i) => Model('model $i'))),
+ );
+ });
+
+ isarTest('.isEmpty()', () async {
+ expect(await isar.models.where().tIsEmpty(), false);
+ expect(await isar.models.where().limit(999999).tIsEmpty(), false);
+ expect(await isar.models.where().limit(1).tIsEmpty(), false);
+ expect(await isar.models.where().limit(0).tIsEmpty(), true);
+
+ expect(
+ await isar.models.filter().valueStartsWith('model').tIsEmpty(),
+ false,
+ );
+ expect(
+ await isar.models.filter().valueEqualTo('model 1').tIsEmpty(),
+ false,
+ );
+ expect(
+ await isar.models.filter().valueStartsWith('non existing').tIsEmpty(),
+ true,
+ );
+ expect(
+ await isar.models
+ .filter()
+ .valueStartsWith('model 1')
+ .and()
+ .valueEqualTo('model 2')
+ .tIsEmpty(),
+ true,
+ );
+ expect(
+ await isar.models
+ .filter()
+ .valueEqualTo('model 1')
+ .or()
+ .valueEqualTo('model 2')
+ .tIsEmpty(),
+ false,
+ );
+
+ await isar.tWriteTxn(() => isar.models.where().limit(99).tDeleteAll());
+
+ expect(await isar.models.where().tIsEmpty(), false);
+ expect(await isar.models.where().limit(999999).tIsEmpty(), false);
+ expect(await isar.models.where().limit(1).tIsEmpty(), false);
+ expect(await isar.models.where().limit(0).tIsEmpty(), true);
+
+ await isar.tWriteTxn(() => isar.models.where().tDeleteAll());
+
+ expect(await isar.models.where().tIsEmpty(), true);
+ expect(await isar.models.where().limit(999999).tIsEmpty(), true);
+ expect(await isar.models.where().limit(1).tIsEmpty(), true);
+ expect(await isar.models.where().limit(0).tIsEmpty(), true);
+
+ await isar.tWriteTxn(() => isar.models.tPut(Model(null)));
+
+ expect(await isar.models.where().tIsEmpty(), false);
+ expect(await isar.models.where().limit(999999).tIsEmpty(), false);
+ expect(await isar.models.where().limit(1).tIsEmpty(), false);
+ expect(await isar.models.where().limit(0).tIsEmpty(), true);
+ });
+
+ isarTest('.isNotEmpty()', () async {
+ expect(await isar.models.where().tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(999999).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(1).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(0).tIsNotEmpty(), false);
+
+ expect(
+ await isar.models.filter().valueStartsWith('model').tIsNotEmpty(),
+ true,
+ );
+ expect(
+ await isar.models.filter().valueEqualTo('model 1').tIsNotEmpty(),
+ true,
+ );
+ expect(
+ await isar.models
+ .filter()
+ .valueStartsWith('non existing')
+ .tIsNotEmpty(),
+ false,
+ );
+ expect(
+ await isar.models
+ .filter()
+ .valueStartsWith('model 1')
+ .and()
+ .valueEqualTo('model 2')
+ .tIsNotEmpty(),
+ false,
+ );
+ expect(
+ await isar.models
+ .filter()
+ .valueEqualTo('model 1')
+ .or()
+ .valueEqualTo('model 2')
+ .tIsNotEmpty(),
+ true,
+ );
+
+ await isar.tWriteTxn(() => isar.models.where().limit(99).tDeleteAll());
+
+ expect(await isar.models.where().tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(999999).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(1).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(0).tIsNotEmpty(), false);
+
+ await isar.tWriteTxn(() => isar.models.where().tDeleteAll());
+
+ expect(await isar.models.where().tIsNotEmpty(), false);
+ expect(await isar.models.where().limit(999999).tIsNotEmpty(), false);
+ expect(await isar.models.where().limit(1).tIsNotEmpty(), false);
+ expect(await isar.models.where().limit(0).tIsNotEmpty(), false);
+
+ await isar.tWriteTxn(() => isar.models.tPut(Model(null)));
+
+ expect(await isar.models.where().tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(999999).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(1).tIsNotEmpty(), true);
+ expect(await isar.models.where().limit(0).tIsNotEmpty(), false);
+ });
+ });
+}

diff:
@@ -185,6 +185,22 @@ extension QueryBuilderExecute<OBJ, R>
}
}
+ Future<bool> tIsEmpty() {
+ if (syncTest) {
+ return SynchronousFuture(isEmptySync());
+ } else {
+ return isEmpty();
+ }
+ }
+
+ Future<bool> tIsNotEmpty() {
+ if (syncTest) {
+ return SynchronousFuture(isNotEmptySync());
+ } else {
+ return isNotEmpty();
+ }
+ }
+
Future<bool> tDeleteFirst() {
if (syncTest) {
return SynchronousFuture(deleteFirstSync());

original_message: Added query isEmpty / isNotEmpty tests


message: Added string isEmpty filter test

diff:
@@ -3,176 +3,166 @@ import 'package:test/test.dart';
import '../util/common.dart';
import '../util/matchers.dart';
+import '../util/sync_async_helper.dart';
part 'filter_string_test.g.dart';
@collection
class StringModel {
- StringModel();
+ StringModel(this.field);
- StringModel.init(this.field);
- Id? id;
+ Id id = Isar.autoIncrement;
- String? field = '';
+ String? field;
@override
// ignore: hash_and_equals
bool operator ==(Object other) =>
other is StringModel && field == other.field;
+
+ @override
+ String toString() {
+ return 'StringModel{id: $id, field: $field}';
+ }
}
void main() {
group('String filter', () {
late Isar isar;
- late IsarCollection<StringModel> col;
late StringModel objEmpty;
late StringModel obj1;
late StringModel obj2;
late StringModel obj3;
late StringModel obj4;
+ late StringModel obj5;
+ late StringModel obj6;
late StringModel objNull;
setUp(() async {
isar = await openTempIsar([StringModelSchema]);
- col = isar.stringModels;
- await isar.writeTxn(() async {
- for (var i = 0; i < 5; i++) {
- final obj = StringModel.init('string $i');
- await col.put(obj);
- }
- await col.put(StringModel.init(null));
- await col.put(StringModel.init(''));
- await col.put(StringModel.init('string 4'));
- });
+ objEmpty = StringModel('');
+ obj1 = StringModel('string 1');
+ obj2 = StringModel('string 2');
+ obj3 = StringModel('string 3');
+ obj4 = StringModel('string 4');
+ obj5 = StringModel('string 5');
+ obj6 = StringModel('string 5');
+ objNull = StringModel(null);
+
+ await isar.writeTxn(
+ () async => isar.stringModels.tPutAll([
+ objEmpty,
+ obj1,
+ obj2,
+ obj3,
+ obj4,
+ obj5,
+ obj6,
+ objNull,
+ ]),
+ );
});
isarTest('.equalTo()', () async {
await qEqual(
- col.filter().fieldEqualTo('string 2'),
- [StringModel.init('string 2')],
+ isar.stringModels.filter().fieldEqualTo('string 2'),
+ [obj2],
);
await qEqual(
- col.filter().fieldEqualTo(null),
- [StringModel.init(null)],
+ isar.stringModels.filter().fieldEqualTo(null),
+ [objNull],
);
await qEqual(
- col.filter().fieldEqualTo('string 5'),
+ isar.stringModels.filter().fieldEqualTo('string 6'),
[],
);
await qEqual(
- col.filter().fieldEqualTo(''),
- [StringModel.init('')],
+ isar.stringModels.filter().fieldEqualTo(''),
+ [objEmpty],
);
});
isarTest('.isNull()', () async {
await qEqual(
- col.filter().fieldIsNull(),
- [StringModel.init(null)],
+ isar.stringModels.filter().fieldIsNull(),
+ [objNull],
);
});
isarTest('.startsWith()', () async {
await qEqualSet(
- col.filter().fieldStartsWith('string'),
- {
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
+ isar.stringModels.filter().fieldStartsWith('string'),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
);
await qEqualSet(
- col.filter().fieldStartsWith(''),
- {
- StringModel.init(''),
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
- );
- await qEqualSet(col.filter().fieldStartsWith('S'), {});
+ isar.stringModels.filter().fieldStartsWith(''),
+ [objEmpty, obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(isar.stringModels.filter().fieldStartsWith('S'), {});
});
isarTest('.endsWith()', () async {
await qEqualSet(
- col.filter().fieldEndsWith('4'),
- {
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
+ isar.stringModels.filter().fieldEndsWith('5'),
+ [obj5, obj6],
);
await qEqualSet(
- col.filter().fieldEndsWith(''),
- {
- StringModel.init(''),
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
- );
- await qEqualSet(col.filter().fieldEndsWith('8'), {});
+ isar.stringModels.filter().fieldEndsWith(''),
+ [objEmpty, obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(isar.stringModels.filter().fieldEndsWith('8'), []);
});
isarTest('.contains()', () async {
- await qEqualSet(col.filter().fieldContains('ing'), {
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- });
await qEqualSet(
- col.filter().fieldContains(''),
- {
- StringModel.init(''),
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
- );
- await qEqualSet(col.where().filter().fieldContains('x'), {});
+ isar.stringModels.filter().fieldContains('ing'),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().fieldContains(''),
+ [objEmpty, obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().filter().fieldContains('x'),
+ [],
+ );
});
- isarTestVm('.matches()', () async {
+ isarTestVm('.matches() VM', () async {
await qEqualSet(
- col.filter().fieldMatches('*ng 4'),
- {
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
+ isar.stringModels.filter().fieldMatches('*ng 5'),
+ [obj5, obj6],
);
await qEqualSet(
- col.filter().fieldMatches('????????'),
- {
- StringModel.init('string 0'),
- StringModel.init('string 1'),
- StringModel.init('string 2'),
- StringModel.init('string 3'),
- StringModel.init('string 4'),
- StringModel.init('string 4'),
- },
+ isar.stringModels.filter().fieldMatches('????????'),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
+ );
+ await qEqualSet(isar.stringModels.filter().fieldMatches(''), [objEmpty]);
+
+ await qEqualSet(isar.stringModels.filter().fieldMatches('*4?'), []);
+ });
+
+ isarTestWeb('.matches() WEB', () async {
+ expect(
+ await isar.stringModels.filter().fieldMatches('*ng 5').tFindAll(),
+ anyOf(throwsUnimplementedError, throwsUnsupportedError),
);
+ });
+
+ isarTest('.isEmpty()', () async {
await qEqualSet(
- col.filter().fieldMatches(''),
- {StringModel.init('')},
+ isar.stringModels.filter().fieldIsEmpty(),
+ [objEmpty],
);
+ });
- await qEqualSet(col.filter().fieldMatches('*4?'), {});
+ isarTest('.isNotEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().fieldIsNotEmpty(),
+ [obj1, obj2, obj3, obj4, obj5, obj6],
+ );
});
});
}

diff:
@@ -102,6 +102,7 @@ void isarTest(
);
},
timeout: timeout ?? const Timeout(Duration(minutes: 10)),
+ skip: skip,
);
}
@@ -119,6 +120,11 @@ void isarTestVm(String name, dynamic Function() body) {
isarTest(name, body, skip: kIsWeb);
}
+@isTest
+void isarTestWeb(String name, dynamic Function() body) {
+ isarTest(name, body, skip: !kIsWeb);
+}
+
@isTest
void isarTestSync(String name, void Function() body) {
isarTest(name, body, skip: kIsWeb, syncOnly: true);

original_message: Added string isEmpty filter test


message: Added filter string list tests

diff:
+import 'package:isar/isar.dart';
+import 'package:test/test.dart';
+
+import '../util/common.dart';
+import '../util/matchers.dart';
+import '../util/sync_async_helper.dart';
+
+part 'filter_string_list_test.g.dart';
+
+@collection
+class StringModel {
+ StringModel({
+ required this.strings,
+ required this.nullableStrings,
+ required this.stringsNullable,
+ required this.nullableStringsNullable,
+ });
+
+ Id id = Isar.autoIncrement;
+
+ List<String> strings;
+ List<String?> nullableStrings;
+ List<String>? stringsNullable;
+ List<String?>? nullableStringsNullable;
+
+ @override
+ // ignore: hash_and_equals
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is StringModel &&
+ runtimeType == other.runtimeType &&
+ id == other.id &&
+ listEquals(strings, other.strings) &&
+ listEquals(nullableStrings, other.nullableStrings) &&
+ listEquals(stringsNullable, other.stringsNullable) &&
+ listEquals(nullableStringsNullable, other.nullableStringsNullable);
+
+ @override
+ String toString() {
+ return '''StringModel{id: $id, strings: $strings, nullableStrings: $nullableStrings, stringsNullable: $stringsNullable, nullableStringsNullable: $nullableStringsNullable}''';
+ }
+}
+
+void main() {
+ group('String list filter', () {
+ late Isar isar;
+
+ late StringModel obj1;
+ late StringModel obj2;
+ late StringModel obj3;
+ late StringModel obj4;
+ late StringModel obj5;
+ late StringModel obj6;
+
+ setUp(() async {
+ isar = await openTempIsar([StringModelSchema]);
+
+ obj1 = StringModel(
+ strings: ['strings 1', 'strings 2', 'strings 3'],
+ nullableStrings: ['nullable strings 1', null, 'nullable strings 3'],
+ stringsNullable: ['strings nullable 1'],
+ nullableStringsNullable: ['nullable strings nullable 1', null, null],
+ );
+ obj2 = StringModel(
+ strings: ['strings 2', 'strings 4'],
+ nullableStrings: [
+ 'nullable strings 2',
+ 'nullable strings 3',
+ 'nullable strings 3',
+ ],
+ stringsNullable: null,
+ nullableStringsNullable: null,
+ );
+ obj3 = StringModel(
+ strings: [],
+ nullableStrings: [],
+ stringsNullable: [],
+ nullableStringsNullable: [],
+ );
+ obj4 = StringModel(
+ strings: ['strings 1', 'strings 5', 'strings 6'],
+ nullableStrings: ['nullable strings 4', 'nullable strings 5'],
+ stringsNullable: [
+ 'strings nullable 4',
+ 'strings nullable 5',
+ 'strings nullable 6',
+ ],
+ nullableStringsNullable: [null, null, null],
+ );
+ obj5 = StringModel(
+ strings: [
+ 'strings 3',
+ 'strings 4',
+ 'strings 5',
+ 'strings 6',
+ 'strings 7',
+ ],
+ nullableStrings: [
+ null,
+ 'nullable strings 3',
+ 'nullable strings 4',
+ 'nullable strings 5',
+ 'nullable strings 6',
+ ],
+ stringsNullable: ['strings nullable 1'],
+ nullableStringsNullable: null,
+ );
+ obj6 = StringModel(
+ strings: [''],
+ nullableStrings: [
+ '',
+ 'nullable strings 2',
+ 'nullable strings 5',
+ 'nullable strings 6',
+ ],
+ stringsNullable: ['strings nullable 4', 'strings nullable 5', ''],
+ nullableStringsNullable: [
+ null,
+ '',
+ 'nullable strings nullable 3',
+ 'nullable strings nullable 5',
+ ],
+ );
+
+ await isar.tWriteTxn(
+ () => isar.stringModels.tPutAll([obj1, obj2, obj3, obj4, obj5, obj6]),
+ );
+ });
+
+ isarTest('.elementEqualTo()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 1'),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 2'),
+ [obj1, obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 3'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 4'),
+ [obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 5'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 6'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('strings 7'),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 1'),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 2'),
+ [obj2, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 3'),
+ [obj1, obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 4'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 5'),
+ [obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('nullable strings 6'),
+ [obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('strings nullable 1'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('strings nullable 4'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('strings nullable 5'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('strings nullable 6'),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEqualTo(
+ 'nullable strings nullable 1',
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEqualTo(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEqualTo(
+ 'nullable strings nullable 5',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementEqualTo('non existing'),
+ [],
+ );
+ });
+
+ isarTest('.elementStartWith()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementStartsWith('strings'),
+ [obj1, obj2, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementStartsWith('nullable'),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementStartsWith('strings'),
+ [obj1, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementStartsWith('nullable'),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementStartsWith('non existing'),
+ [],
+ );
+ });
+
+ isarTest('.elementEndsWith()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('1'),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('2'),
+ [obj1, obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('3'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('4'),
+ [obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('5'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('6'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('7'),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementEndsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('1'),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('2'),
+ [obj2, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('3'),
+ [obj1, obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('4'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('5'),
+ [obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementEndsWith('6'),
+ [obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementEndsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementEndsWith('1'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementEndsWith('4'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementEndsWith('5'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementEndsWith('6'),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementEndsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEndsWith('1'),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEndsWith('3'),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementEndsWith('5'),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementEndsWith('non existing'),
+ [],
+ );
+ });
+
+ isarTest('.elementContains()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementContains('ings'),
+ [obj1, obj2, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementContains('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementContains('ings'),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementContains('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementContains('ings'),
+ [obj1, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementContains('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementContains('ings'),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementContains('non existing'),
+ [],
+ );
+ });
+
+ isarTestVm('.elementMatches() VM', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementMatches('?????????'),
+ [obj1, obj2, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementMatches('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementMatches('??????????????????'),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementMatches('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementMatches('??????????????????'),
+ [obj1, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementMatches('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementMatches(
+ '???????????????????????????',
+ ),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsNullableElementMatches('non existing'),
+ [],
+ );
+ });
+
+ isarTestWeb('.elementMatches() WEB', () async {
+ expect(
+ await isar.stringModels
+ .filter()
+ .stringsElementMatches('?????????')
+ .tFindAll(),
+ anyOf(throwsUnimplementedError, throwsUnsupportedError),
+ );
+
+ expect(
+ await isar.stringModels
+ .filter()
+ .nullableStringsElementMatches('??????????????????')
+ .tFindAll(),
+ anyOf(throwsUnimplementedError, throwsUnsupportedError),
+ );
+
+ expect(
+ await isar.stringModels
+ .filter()
+ .stringsNullableElementMatches('??????????????????')
+ .tFindAll(),
+ anyOf(throwsUnimplementedError, throwsUnsupportedError),
+ );
+
+ expect(
+ await isar.stringModels
+ .filter()
+ .nullableStringsNullableElementContains(
+ '???????????????????????????',
+ )
+ .tFindAll(),
+ anyOf(throwsUnimplementedError, throwsUnsupportedError),
+ );
+ });
+
+ isarTest('.elementIsNull()', () async {
+ // FIXME: method `elementIsNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.filter().nullableStringsElementIsNull(),
+ // [obj1, obj5],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementIsNull(),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.elementIsNotNull()', () async {
+ // FIXME: method `elementIsNotNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.filter().nullableStringsElementIsNotNull(),
+ // [obj1, obj2, obj4, obj5, obj6],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementIsNotNull(),
+ [obj1, obj6],
+ );
+ });
+
+ isarTest('.elementGreaterThan()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementGreaterThan('strings 3'),
+ [obj2, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementGreaterThan('nullable strings 3'),
+ [obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementGreaterThan('strings nullable 3'),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementGreaterThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+ });
+
+ // FIXME: .elementLessThan() doesn't seem to be working
+ // (returns either no elements or null elements)
+ isarTest('.elementLessThan()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementLessThan('strings 3'),
+ [obj1, obj2, obj4],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .nullableStringsElementLessThan('nullable strings 3'),
+ [obj1, obj2, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsNullableElementLessThan('strings nullable 3'),
+ [obj1, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementLessThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.elementBetween()', () async {
+ await qEqualSet(
+ isar.stringModels
+ .filter()
+ .stringsElementBetween('strings 2', 'strings 4'),
+ [obj1, obj2, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementBetween(
+ 'nullable strings 2',
+ 'nullable strings 4',
+ ),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementBetween(
+ 'strings nullable 2',
+ 'strings nullable 4',
+ ),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementBetween(
+ 'nullable strings nullable 2',
+ 'nullable strings nullable 4',
+ ),
+ [obj6],
+ );
+ });
+
+ isarTest('.elementIsEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementIsEmpty(),
+ [obj6],
+ );
+ });
+
+ isarTest('.elementIsNotEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsElementIsNotEmpty(),
+ [obj1, obj2, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsElementIsNotEmpty(),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableElementIsNotEmpty(),
+ [obj1, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableElementIsNotEmpty(),
+ [obj1, obj6],
+ );
+ });
+
+ isarTest('.lengthEqualTo()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthEqualTo(0),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthEqualTo(1),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthEqualTo(2),
+ [obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthEqualTo(3),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthEqualTo(5),
+ [obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthEqualTo(0),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthEqualTo(2),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthEqualTo(3),
+ [obj1, obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthEqualTo(4),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthEqualTo(5),
+ [obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthEqualTo(0),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthEqualTo(1),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthEqualTo(3),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthEqualTo(0),
+ [obj3],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthEqualTo(3),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthEqualTo(4),
+ [obj6],
+ );
+ });
+
+ isarTest('.lengthGreaterThan()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthGreaterThan(2),
+ [obj1, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthGreaterThan(2),
+ [obj1, obj2, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthGreaterThan(2),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthGreaterThan(2),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.lengthLessThan()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthLessThan(2),
+ [obj3, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthLessThan(2),
+ [obj3],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthLessThan(2),
+ [obj1, obj3, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthLessThan(2),
+ [obj3],
+ );
+ });
+
+ isarTest('.lengthBetween()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsLengthBetween(2, 4),
+ [obj1, obj2, obj4],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsLengthBetween(2, 4),
+ [obj1, obj2, obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableLengthBetween(2, 4),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableLengthBetween(2, 4),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.isEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsIsEmpty(),
+ [obj3],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsIsEmpty(),
+ [obj3],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableIsEmpty(),
+ [obj3],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableIsEmpty(),
+ [obj3],
+ );
+ });
+
+ isarTest('.isNotEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsIsNotEmpty(),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsIsNotEmpty(),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableIsNotEmpty(),
+ [obj1, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableIsNotEmpty(),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.isNull()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableIsNull(),
+ [obj2],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableIsNull(),
+ [obj2, obj5],
+ );
+ });
+
+ isarTest('.isNotNull()', () async {
+ await qEqualSet(
+ isar.stringModels.filter().stringsNullableIsNotNull(),
+ [obj1, obj3, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.filter().nullableStringsNullableIsNotNull(),
+ [obj1, obj3, obj4, obj6],
+ );
+ });
+ });
+}

original_message: Added filter string list tests


message: Added string list where tests

diff:
@@ -606,11 +606,12 @@ void main() {
});
// FIXME: .elementLessThan() doesn't seem to be working
- // (returns either no elements or null elements)
+ // returns either no elements or null elements
+ // also works fine in the index test
isarTest('.elementLessThan()', () async {
await qEqualSet(
isar.stringModels.filter().stringsElementLessThan('strings 3'),
- [obj1, obj2, obj4],
+ [obj1, obj2, obj4, obj6],
);
await qEqualSet(
@@ -624,7 +625,7 @@ void main() {
isar.stringModels
.filter()
.stringsNullableElementLessThan('strings nullable 3'),
- [obj1, obj5],
+ [obj1, obj5, obj6],
);
await qEqualSet(

diff:
@@ -3,45 +3,889 @@ import 'package:test/test.dart';
import '../util/common.dart';
import '../util/matchers.dart';
+import '../util/sync_async_helper.dart';
part 'where_string_list_test.g.dart';
@collection
class StringModel {
- StringModel();
+ StringModel({
+ required this.values,
+ required this.nullableValues,
+ required this.valuesNullable,
+ required this.nullableValuesNullable,
+ }) : hash = values,
+ nullableHash = nullableValues,
+ hashNullable = valuesNullable,
+ nullableHashNullable = nullableValuesNullable,
+ hashes = values,
+ nullableHashes = nullableValues,
+ hashesNullable = valuesNullable,
+ nullableHashesNullable = nullableValuesNullable;
- StringModel.init(this.list)
- : hashList = list,
- hashElementList = list;
+ Id id = Isar.autoIncrement;
- Id? id;
+ @Index(type: IndexType.value)
+ List<String> values;
+
+ @Index(type: IndexType.value)
+ List<String?> nullableValues;
@Index(type: IndexType.value)
- List<String>? list;
+ List<String>? valuesNullable;
+
+ @Index(type: IndexType.value)
+ List<String?>? nullableValuesNullable;
+
+ @Index(type: IndexType.hash)
+ List<String> hash;
@Index(type: IndexType.hash)
- List<String>? hashList;
+ List<String?> nullableHash;
+
+ @Index(type: IndexType.hash)
+ List<String>? hashNullable;
+
+ @Index(type: IndexType.hash)
+ List<String?>? nullableHashNullable;
+
+ @Index(type: IndexType.hashElements)
+ List<String> hashes;
@Index(type: IndexType.hashElements)
- List<String>? hashElementList;
+ List<String?> nullableHashes;
+
+ @Index(type: IndexType.hashElements)
+ List<String>? hashesNullable;
+
+ @Index(type: IndexType.hashElements)
+ List<String?>? nullableHashesNullable;
@override
// ignore: hash_and_equals
- bool operator ==(Object other) {
- if (other is StringModel) {
- return listEquals(list, other.list) &&
- listEquals(hashList, other.hashList) &&
- listEquals(hashElementList, other.hashElementList);
- }
- return false;
+ bool operator ==(Object other) =>
+ identical(this, other) ||
+ other is StringModel &&
+ runtimeType == other.runtimeType &&
+ id == other.id &&
+ listEquals(values, other.values) &&
+ listEquals(nullableValues, other.nullableValues) &&
+ listEquals(valuesNullable, other.valuesNullable) &&
+ listEquals(nullableValuesNullable, other.nullableValuesNullable) &&
+ listEquals(hash, other.hash) &&
+ listEquals(nullableHash, other.nullableHash) &&
+ listEquals(hashNullable, other.hashNullable) &&
+ listEquals(nullableHashNullable, other.nullableHashNullable) &&
+ listEquals(hashes, other.hashes) &&
+ listEquals(nullableHashes, other.nullableHashes) &&
+ listEquals(hashesNullable, other.hashesNullable) &&
+ listEquals(nullableHashesNullable, other.nullableHashesNullable);
+
+ @override
+ String toString() {
+ return '''StringModel{id: $id, values: $values, nullableValues: $nullableValues, valuesNullable: $valuesNullable, nullableValuesNullable: $nullableValuesNullable, hash: $hash, nullableHash: $nullableHash, hashNullable: $hashNullable, nullableHashNullable: $nullableHashNullable, hashes: $hashes, nullableHashes: $nullableHashes, hashesNullable: $hashesNullable, nullableHashesNullable: $nullableHashesNullable}''';
}
}
void main() {
group('Where String list', () {
late Isar isar;
- late IsarCollection<StringModel> col;
+
+ late StringModel obj1;
+ late StringModel obj2;
+ late StringModel obj3;
+ late StringModel obj4;
+ late StringModel obj5;
+ late StringModel obj6;
+
+ setUp(() async {
+ isar = await openTempIsar([StringModelSchema]);
+
+ obj1 = StringModel(
+ values: ['strings 1', 'strings 2', 'strings 3'],
+ nullableValues: ['nullable strings 1', null, 'nullable strings 3'],
+ valuesNullable: ['strings nullable 1'],
+ nullableValuesNullable: ['nullable strings nullable 1', null, null],
+ );
+ obj2 = StringModel(
+ values: ['strings 2', 'strings 4'],
+ nullableValues: [
+ 'nullable strings 2',
+ 'nullable strings 3',
+ 'nullable strings 3',
+ ],
+ valuesNullable: null,
+ nullableValuesNullable: null,
+ );
+ obj3 = StringModel(
+ values: [],
+ nullableValues: [],
+ valuesNullable: [],
+ nullableValuesNullable: [],
+ );
+ obj4 = StringModel(
+ values: ['strings 1', 'strings 5', 'strings 6'],
+ nullableValues: ['nullable strings 4', 'nullable strings 5'],
+ valuesNullable: [
+ 'strings nullable 4',
+ 'strings nullable 5',
+ 'strings nullable 6',
+ ],
+ nullableValuesNullable: [null, null, null],
+ );
+ obj5 = StringModel(
+ values: [
+ 'strings 3',
+ 'strings 4',
+ 'strings 5',
+ 'strings 6',
+ 'strings 7',
+ ],
+ nullableValues: [
+ null,
+ 'nullable strings 3',
+ 'nullable strings 4',
+ 'nullable strings 5',
+ 'nullable strings 6',
+ ],
+ valuesNullable: ['strings nullable 1'],
+ nullableValuesNullable: null,
+ );
+ obj6 = StringModel(
+ values: [''],
+ nullableValues: [
+ '',
+ 'nullable strings 2',
+ 'nullable strings 5',
+ 'nullable strings 6',
+ ],
+ valuesNullable: ['strings nullable 4', 'strings nullable 5', ''],
+ nullableValuesNullable: [
+ null,
+ '',
+ 'nullable strings nullable 3',
+ 'nullable strings nullable 5',
+ ],
+ );
+
+ await isar.tWriteTxn(
+ () => isar.stringModels.tPutAll([obj1, obj2, obj3, obj4, obj5, obj6]),
+ );
+ });
+
+ isarTest('.elementEqualTo()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 1'),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 2'),
+ [obj1, obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 3'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 4'),
+ [obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 5'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 6'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('strings 7'),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 1'),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 2'),
+ [obj2, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 3'),
+ [obj1, obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 4'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 5'),
+ [obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementEqualTo('nullable strings 6'),
+ [obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementEqualTo('strings nullable 1'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementEqualTo('strings nullable 4'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementEqualTo('strings nullable 5'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementEqualTo('strings nullable 6'),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementEqualTo(
+ 'nullable strings nullable 1',
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementEqualTo(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementEqualTo(
+ 'nullable strings nullable 5',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 1'),
+ [obj1, obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 2'),
+ [obj1, obj2],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 3'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 4'),
+ [obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 5'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 6'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('strings 7'),
+ [obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 1'),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 2'),
+ [obj2, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 3'),
+ [obj1, obj2, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 4'),
+ [obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 5'),
+ [obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementEqualTo('nullable strings 6'),
+ [obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementEqualTo('strings nullable 1'),
+ [obj1, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementEqualTo('strings nullable 4'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementEqualTo('strings nullable 5'),
+ [obj4, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementEqualTo('strings nullable 6'),
+ [obj4],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementEqualTo(
+ 'nullable strings nullable 1',
+ ),
+ [obj1],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementEqualTo(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementEqualTo(
+ 'nullable strings nullable 5',
+ ),
+ [obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesNullableElementEqualTo('non existing'),
+ [],
+ );
+ });
+
+ isarTest('.elementStartWith()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementStartsWith('strings'),
+ [obj1, obj2, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesElementStartsWith('nullable'),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementStartsWith('strings'),
+ [obj1, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesNullableElementStartsWith('nullable'),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesNullableElementStartsWith('non existing'),
+ [],
+ );
+
+ // FIXME: hashElements indexes not working properly with
+ // `elementStartsWith`.
+ // Should the method be generated? I don't think `startsWith` is suppose
+ // to work on a hashed value.
+ // Does not return values when supposed to, and returns values when not
+ // supposed to
+ await qEqualSet(
+ isar.stringModels.where().hashesElementStartsWith('strings'),
+ [obj1, obj2, obj4, obj5],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesElementStartsWith('nullable'),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementStartsWith('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().hashesNullableElementStartsWith('strings'),
+ [obj1, obj4, obj5, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels.where().hashesNullableElementEqualTo('non existing'),
+ [],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesNullableElementStartsWith('nullable'),
+ [obj1, obj6],
+ );
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesNullableElementStartsWith('non existing'),
+ [],
+ );
+ });
+
+ isarTest('.elementIsNull()', () async {
+ // FIXME: method `elementIsNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.where().nullableValuesElementIsNull(),
+ // [obj1, obj5],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementIsNull(),
+ [obj1, obj4, obj6],
+ );
+
+ // FIXME: method `elementIsNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.where().nullableHashesElementIsNull(),
+ // [obj1, obj5],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementIsNull(),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.elementIsNotNull()', () async {
+ // FIXME: method `elementIsNotNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.filter().nullableValuesElementIsNotNull(),
+ // [obj1, obj2, obj4, obj5, obj6],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementIsNotNull(),
+ [obj1, obj6],
+ );
+
+ // FIXME: method `elementIsNotNull()` not generated on `List<String?>`
+ // but are generated on `List<String>?`, which shouldn't, since element
+ // is not nullable
+ // await qEqualSet(
+ // isar.stringModels.filter().nullableHashesElementIsNotNull(),
+ // [obj1, obj2, obj4, obj5, obj6],
+ // );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementIsNotNull(),
+ [obj1, obj6],
+ );
});
- // TODO
+ isarTest('.elementGreaterThan()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementGreaterThan('strings 3'),
+ [obj2, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementGreaterThan('nullable strings 3'),
+ [obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementGreaterThan('strings nullable 3'),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementGreaterThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+
+ // FIXME: hashElements indexes not working properly with
+ // `elementGreaterThan`.
+ // Should the method be generated?
+ await qEqualSet(
+ isar.stringModels.where().hashesElementGreaterThan('strings 3'),
+ [obj2, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementGreaterThan('nullable strings 3'),
+ [obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementGreaterThan('strings nullable 3'),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementGreaterThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj6],
+ );
+ });
+
+ isarTest('.elementLessThan()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementLessThan('strings 3'),
+ [obj1, obj2, obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableValuesElementLessThan('nullable strings 3'),
+ [obj1, obj2, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesNullableElementLessThan('strings nullable 3'),
+ [obj1, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementLessThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj1, obj4, obj6],
+ );
+
+ // FIXME: hashElements indexes not working properly with
+ // `elementLessThan`.
+ // Should the method be generated?
+ await qEqualSet(
+ isar.stringModels.where().hashesElementLessThan('strings 3'),
+ [obj1, obj2, obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .nullableHashesElementLessThan('nullable strings 3'),
+ [obj1, obj2, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesNullableElementLessThan('strings nullable 3'),
+ [obj1, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementLessThan(
+ 'nullable strings nullable 3',
+ ),
+ [obj1, obj4, obj6],
+ );
+ });
+
+ isarTest('.elementBetween()', () async {
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .valuesElementBetween('strings 2', 'strings 4'),
+ [obj1, obj2, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesElementBetween(
+ 'nullable strings 2',
+ 'nullable strings 4',
+ ),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementBetween(
+ 'strings nullable 2',
+ 'strings nullable 4',
+ ),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementBetween(
+ 'nullable strings nullable 2',
+ 'nullable strings nullable 4',
+ ),
+ [obj6],
+ );
+
+ // FIXME: hashElements indexes not working properly with
+ // `elementBetween`.
+ // Should the method be generated?
+ await qEqualSet(
+ isar.stringModels
+ .where()
+ .hashesElementBetween('strings 2', 'strings 4'),
+ [obj1, obj2, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesElementBetween(
+ 'nullable strings 2',
+ 'nullable strings 4',
+ ),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().hashesNullableElementBetween(
+ 'strings nullable 2',
+ 'strings nullable 4',
+ ),
+ [obj4, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashesNullableElementBetween(
+ 'nullable strings nullable 2',
+ 'nullable strings nullable 4',
+ ),
+ [obj6],
+ );
+ });
+
+ // TODO(Jtplouffe): `.elementIsEmpty()` not yet implemented on indexes
+ /*
+ isarTest('.elementIsEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementIsEmpty(),
+ [obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementIsEmpty(),
+ [obj6],
+ );
+ });
+ */
+
+ // TODO(Jtplouffe): `.elementIsEmpty()` not yet implemented on indexes
+ /*
+ isarTest('.elementIsNotEmpty()', () async {
+ await qEqualSet(
+ isar.stringModels.where().valuesElementIsNotEmpty(),
+ [obj1, obj2, obj4, obj5],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesElementIsNotEmpty(),
+ [obj1, obj2, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().valuesNullableElementIsNotEmpty(),
+ [obj1, obj4, obj5, obj6],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableValuesNullableElementIsNotEmpty(),
+ [obj1, obj6],
+ );
+ });
+ */
+
+ // FIXME: Should `.lengthXXX()` / `.isEmpty` be implemented on `values`
+ // and `hashElements` indexes?
+
+ isarTest('.isNull()', () async {
+ // FIXME: `.isNull()` is not generated on type List<String>?
+ // await qEqualSet(
+ // isar.stringModels.where().valuesNullableIsNull(),
+ // [obj2],
+ // );
+
+ // FIXME: `.isNull()` is not generated on type List<String?>?
+ // await qEqualSet(
+ // isar.stringModels.where().nullableValuesNullableIsNull(),
+ // [obj2, obj5],
+ // );
+
+ // FIXME: empty array also returned (obj2 & obj3 instead of only obj2)
+ await qEqualSet(
+ isar.stringModels.where().hashNullableIsNull(),
+ [obj2],
+ );
+
+ await qEqualSet(
+ isar.stringModels.where().nullableHashNullableIsNull(),
+ [obj2, obj5],
+ );
+
+ // FIXME: `.isNull()` is not generated on type List<String>?
+ // await qEqualSet(
+ // isar.stringModels.where().hashesNullableIsNull(),
+ // [obj2],
+ // );
+
+ // FIXME: `.isNull()` is not generated on type List<String?>?
+ // await qEqualSet(
+ // isar.stringModels.where().nullableHashesNullableIsNull(),
+ // [obj2, obj5],
+ // );
+ });
+
+ isarTest('.isNotNull()', () async {
+ // FIXME: `.isNotNull()` is not generated on type List<String>?
+ // await qEqualSet(
+ // isar.stringModels.where().valuesNullableIsNotNull(),
+ // [obj1, obj3, obj4, obj5, obj6],
+ // );
+
+ // FIXME: `.isNotNull()` is not generated on type List<String?>?
+ // await qEqualSet(
+ // isar.stringModels.where().nullableValuesNullableIsN(),
+ // [obj1, obj3, obj4, obj6],
+ // );
+
+ // FIXME: Returning wrong values
+ await qEqualSet(
+ isar.stringModels.where().hashNullableIsNotNull(),
+ [obj1, obj3, obj4, obj5, obj6],
+ );
+
+ // FIXME: Returning wrong values
+ await qEqualSet(
+ isar.stringModels.where().nullableHashNullableIsNotNull(),
+ [obj1, obj3, obj4, obj6],
+ );
+
+ // FIXME: `.isNotNull()` is not generated on type List<String>?
+ // await qEqualSet(
+ // isar.stringModels.where().hashesNullableIsNotNull(),
+ // [obj1, obj3, obj4, obj5, obj6],
+ // );
+
+ // FIXME: `.isNotNull()` is not generated on type List<String?>?
+ // await qEqualSet(
+ // isar.stringModels.where().nullableHashesNullableIsNotNull(),
+ // [obj1, obj3, obj4, obj6],
+ // );
+ });
+ });
}

original_message: Added string list where tests