Skip to content

Commit

Permalink
Add test case to show bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed Aug 8, 2024
1 parent 546d349 commit b1e34af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/realm_dart/lib/realm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

// dart.library.cli is available only on dart desktop
export 'src/realm_flutter.dart' if (dart.library.cli) 'src/realm_dart.dart';
export 'package:ejson/ejson.dart';
export 'package:ejson/ejson.dart';
14 changes: 14 additions & 0 deletions packages/realm_dart/test/results_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1550,4 +1550,18 @@ void main() {
expect(results.skip(2), results.toList().sublist(2));
expect(results.skip(2).take(3), [results[2], results[3], results[4]]);
});

test('BETWEEN op', () {
final realm = getRealm(Configuration.local([Friend.schema, Party.schema]));

final alice = Friend('alice', age: 36);
final bob = Friend('bob', age: 49, bestFriend: alice);
alice.bestFriend = bob;

realm.write(() => realm.addAll([alice, bob]));

expect(realm.query<Friend>(r'age BETWEEN {$0, $1}', [20, 40]), [alice]);
// the following used to fail due to: https://github.com/realm/realm-core/issues/7935
expect(realm.query<Friend>(r'bestFriend.age BETWEEN {$0, $1}', [20, 40]), [bob]);
});
}
3 changes: 3 additions & 0 deletions packages/realm_dart/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ class _Friend {
var age = 42;
_Friend? bestFriend;
final friends = <_Friend>[];

@override
String toString() => '$name $age';
}

@RealmModel()
Expand Down

0 comments on commit b1e34af

Please sign in to comment.