-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Results of primitives #893
Conversation
Pull Request Test Coverage Report for Build 3322498460
💛 - Coveralls |
2aaea08
to
d5c2af3
Compare
02cedea
to
376729d
Compare
d5c2af3
to
e2e7315
Compare
18a009d
to
e72bd4f
Compare
f1fe4c0
to
c093026
Compare
c093026
to
8034b07
Compare
ea2e7cc
to
5dc7caa
Compare
523cd5d
to
4ea3988
Compare
5dc7caa
to
5ab0a40
Compare
4ea3988
to
03eb130
Compare
c7125a4
to
81beb39
Compare
03eb130
to
81e0810
Compare
81beb39
to
d6334af
Compare
81e0810
to
4531a9b
Compare
4531a9b
to
5ea1310
Compare
5ea1310
to
70b6cdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some suggestions
lib/src/results.dart
Outdated
RealmResults<T> query(String query, [List<Object> args = const []]) { | ||
final handle = realmCore.queryResults(this, query, args); | ||
return RealmResultsInternal.create<T>(handle, realm, _metadata); | ||
final meta = _metadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not check if T is RealmObjectBase which is the real marker if this can create objects or it is a results of primitives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can check either one, but we should assert on the other - i.e. if we get a RealmObjectBase
with no meta or meta with a non-RealmObjectBase generic, that would be a bug in the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we can assert the metadata, but I think we should only check the type is RealmObjectBase
since this is the real marker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reworked this to check on type instead. Assert on _meta != null
is implicit in:
final handle = realmCore.resultsGetObjectAt(this, index);
final accessor = RealmCoreAccessor(metadata, realm.isInMigration);
I expect the first line to fail, and otherwise metadata => _metadata!
will.
Object? resultsGetElementAt(RealmResults results, int index) { | ||
return using((Arena arena) { | ||
final realm_value = arena<realm_value_t>(); | ||
_realmLib.invokeGetBool(() => _realmLib.realm_results_get(results.handle._pointer, index, realm_value)); | ||
return realm_value.toDartValue(results.realm); | ||
}); | ||
} | ||
|
||
RealmObjectHandle resultsGetObjectAt(RealmResults results, int index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are those different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one is returning a RealmObject
while the other is returning a realm_value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that. Since realm_value
can hold objects, why not use the same method for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to convert the handle (toDartValue
don't/can't), and the later is less efficient.
3f1449e
to
bb15f26
Compare
Moves results of objects specific functionality to extension method to avoid misuse.
bb15f26
to
f28f1b2
Compare
@@ -4,6 +4,8 @@ | |||
|
|||
### Enhancements | |||
* Added `MutableSubscriptionSet.removeByType` for removing subscriptions by their realm object type. (Issue [#317](https://github.com/realm/realm-dart/issues/317)) | |||
* Support results of primitives, ie. `RealmResult<int>`. (Issue [#162](https://github.com/realm/realm-dart/issues/162)) | |||
* Support notifications on all managed realm lists, including list of primitives, ie. `RealmList<int>.changes` is supported. ([#893](https://github.com/realm/realm-dart/pull/893)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Support notifications on all managed realm lists, including list of primitives, ie. `RealmList<int>.changes` is supported. ([#893](https://github.com/realm/realm-dart/pull/893)) | |
* Support notifications on all managed `RealmList`s, including list of primitive types, for example: `RealmList<int>.changes` is supported. ([#893](https://github.com/realm/realm-dart/pull/893)) |
Resolves #162