-
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
Expose dynamic Realm API #495
Conversation
Pull Request Test Coverage Report for Build 2225904910
💛 - Coveralls |
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.
All tests pass, and we have a string based interface. However, I think the DynamicRealm
should traffic in dynamic
s with runtime type DynamicRealmObject
and that these should overload noSuchMethod
to access the right properties.
There are three reasons why I didn't go for
|
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.
It does expose RealmObject.get<T>
which could use some polish (I don't like it returns Object?), but perhaps that can be addressed later.
I believe RealmObject.get has always been exposed - that's what is used in the generated classes. We use it in tests, but I haven't changed the visibility of it (at least not intentionally). |
065ac4f
to
09168af
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.
Is it possible to have flexible sync subscription by dynamic query?
|
||
/// A collection of [SchemaObject] that will be used to construct the | ||
/// [RealmSchema] once the Realm is opened. | ||
final Iterable<SchemaObject> schemaObjects; |
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.
Note for reviewers: this is replacing the RealmSchema
field that previously existed on the configuration. The reason is that it's now possible to provide an empty collection and have the schema be read from the file. We're now exposing the schema
on the Realm
instance directly as that can only be truly known after we've opened the file. I wanted to make that distinction more explicit, which is why I opted to change the field on the configuration (otherwise we'd have realm.schema != realm.config.schema
and that felt very awkward).
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.
In general I think we should not be exposing the dynamic API except in migrations. We should be building a typed SDK instead of dynamic one and hence the SDK interface should be typed.
I tried to thoroughly review the changes since these are fundamental to the SDK internals
I have been constantly thinking and revisiting this PR for the last weeks and I think we are doing a step in the wrong direction here. I have taken a look at how Realm Swift does this and am I really leaning towards a similar solution for Realm Flutter. I think Realm .NET made a mistake by enabling a generic dynamic API available at all times, which is only required while doing migrations. Instead I believe we should be providing this API only in the migration callback as Realm Swift does. We have this generic |
String-based property setting/getting seems to be available via subscripts, like It also has Virtually all of our SDKs offer dynamic and static API (except JS which only offers dynamic) and while I agree that the dynamic API are niche and mostly useful for migrations, I do not agree that exposing them is a mistake. It makes the SDK more powerful and gives developers flexibility. |
We have discussed internally and it seems we need a dynamic API in the Dart SDK to support certain use cases like app users building the Realm schema at runtime etc. My comments about the |
Delete unneeded test Update changelog
5edab72
to
f773258
Compare
I have inlined |
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.
Added some questions?
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 resolved most previous comments, still I have some here.
@blagoev refactored the while loops to use recursion. While I don't see much of a difference, it's not a hill I'm willing to die on, so can you take another look and see if there's anything left or we can merge. |
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.
Thanks @nirinchev. Lets merge it.
It is not perfect in both ways. But it is accectable. |
This exposes a set of string-based access API for the Realm. The current PR touches only the Realm entrypoint and a follow-up PR will be done to improve the experience when working with objects. The API is as follows
Note: One can use the
RealmObject.get<...>(...)
API to then read properties on the object, but those will change in the future, so not showing them in the example.This is a part of #70.
Fixes #690.