-
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 RealmValue (aka mixed) (#1051)
* Support RealmValue (aka Mixed) in generator * Add generator test of RealmValue * export RealmValue * fix core * RealmValue tests (wip) * Fix RealmCoreAccessor.get * Add RealmValue.from factory * More tests * RealmValue.value now nullable * Refactor nullability * Support RealmList<RealmValue> * Better test * Fix generator tests * Test error message on nullable realm values * Update CHANGELOG * Support realm object in RealmValue + extra tests * cleanup before review * Address PR feedback * Add tests for @indexed() and @PrimaryKey() on RealmValue * Disallow embedded objects in RealmValue (capture in type system) * Simplify initializer generation * Remove some dead code * Add test for unknown object type in RealmValue, but currently disabled as it crashes * Don't add AsymmetricObjectMarker yet * Avoid assertion crash on realm_get_object if classKey is unknown to object store
- Loading branch information
Showing
22 changed files
with
611 additions
and
65 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
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,8 @@ | ||
import 'package:realm_common/realm_common.dart'; | ||
|
||
//part 'nullable_list.g.dart'; | ||
|
||
@RealmModel() | ||
class _Bad { | ||
RealmValue? wrong; | ||
} |
12 changes: 12 additions & 0 deletions
12
generator/test/error_test_data/nullable_realm_value.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
RealmValue fields cannot be nullable | ||
|
||
in: asset:pkg/test/error_test_data/nullable_realm_value.dart:7:3 | ||
╷ | ||
5 │ @RealmModel() | ||
6 │ class _Bad { | ||
│ ━━━━ in realm model for 'Bad' | ||
7 │ RealmValue? wrong; | ||
│ ^^^^^^^^^^^ RealmValue? is nullable | ||
╵ | ||
Change type to RealmValue | ||
|
8 changes: 8 additions & 0 deletions
8
generator/test/error_test_data/realm_value_not_allowed_as_primary_key.dart
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,8 @@ | ||
import 'package:realm_common/realm_common.dart'; | ||
|
||
@RealmModel() | ||
@MapTo('Bad') | ||
class _Foo { | ||
@PrimaryKey() | ||
late RealmValue bad; | ||
} |
16 changes: 16 additions & 0 deletions
16
generator/test/error_test_data/realm_value_not_allowed_as_primary_key.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Realm only supports the @PrimaryKey() annotation on fields of type | ||
int, String, DateTime, ObjectId, Uuid | ||
as well as their nullable versions | ||
|
||
in: asset:pkg/test/error_test_data/realm_value_not_allowed_as_primary_key.dart:7:8 | ||
╷ | ||
3 │ @RealmModel() | ||
4 │ @MapTo('Bad') | ||
5 │ class _Foo { | ||
│ ━━━━ in realm model for 'Foo' | ||
6 │ @PrimaryKey() | ||
7 │ late RealmValue bad; | ||
│ ^^^^^^^^^^ RealmValue is not a valid type here | ||
╵ | ||
Change the type of 'bad', or remove the @PrimaryKey() 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
Oops, something went wrong.