-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support indexes on all compatible types (#875)
* Support indexes on all indexable types * Fix bad tests. Bool is actually indexable now. However, it is not possible to use bool (or bool?) as primary key. * Update test all_types.dart * Add good test for all indexable types * Update CHANGELOG * Apply suggestions from code review Co-authored-by: Nikola Irinchev <[email protected]> * Add test of index speedup * Remove Base. No longer needed * Only display measurements on test failure * Reinstate doc comment on RealmPropertyType * Tweak comment regarding AOT compilation Co-authored-by: Nikola Irinchev <[email protected]>
- Loading branch information
Showing
18 changed files
with
608 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
generator/test/error_test_data/bool_not_allowed_on_indexed_field.dart
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
generator/test/error_test_data/bool_not_allowed_on_indexed_field.expected
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import 'dart:ffi'; | ||
import 'package:realm_common/realm_common.dart'; | ||
|
||
//part 'not_an_indexable_type.g.dart'; | ||
|
||
@RealmModel() | ||
class _Bad { | ||
@Indexed() | ||
late Double notAnIndexableType; | ||
late double notAnIndexableType; | ||
} |
16 changes: 9 additions & 7 deletions
16
generator/test/error_test_data/not_an_indexable_type.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
Realm only support indexes on String, int, and bool fields | ||
Realm only supports the @Indexed() annotation on fields of type | ||
int, bool, String, DateTime, ObjectId, Uuid | ||
as well as their nullable versions | ||
|
||
in: asset:pkg/test/error_test_data/not_an_indexable_type.dart:9:8 | ||
in: asset:pkg/test/error_test_data/not_an_indexable_type.dart:8:8 | ||
╷ | ||
6 │ @RealmModel() | ||
7 │ class _Bad { | ||
5 │ @RealmModel() | ||
6 │ class _Bad { | ||
│ ━━━━ in realm model for 'Bad' | ||
8 │ @Indexed() | ||
9 │ late Double notAnIndexableType; | ||
│ ^^^^^^ Double is not an indexable type | ||
7 │ @Indexed() | ||
8 │ late double notAnIndexableType; | ||
│ ^^^^^^ double is not a valid type here | ||
╵ | ||
Change the type of 'notAnIndexableType', or remove the @Indexed() annotation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:realm_common/realm_common.dart'; | ||
|
||
// part 'indexable_types.g.dart'; | ||
|
||
@RealmModel() | ||
class _Indexable { | ||
@Indexed() | ||
late bool aBool; | ||
@Indexed() | ||
bool? aNullableBool; | ||
@Indexed() | ||
late int anInt; | ||
@Indexed() | ||
int? aNullableInt; | ||
@Indexed() | ||
late String aString; | ||
@Indexed() | ||
String? aNullableString; | ||
@Indexed() | ||
late ObjectId anObjectId; | ||
@Indexed() | ||
ObjectId? aNullableObjectId; | ||
@Indexed() | ||
late Uuid anUuid; | ||
@Indexed() | ||
Uuid? aNullableUuid; | ||
@Indexed() | ||
late DateTime aDateTime; | ||
@Indexed() | ||
DateTime? aNullableDateTime; | ||
} |
Oops, something went wrong.