Adding `distinct()` to RealmList
For consistency, RealmQuery.distinct() and RealmResults.distinct() should be added.
https://github.com/realm/realm-core/issues/1064 is still open. Should we add the Waiting-Core label again? @kneth
I believe it was added to core release 0.95.4 but I will try to get it confirmed.
@dalinaum Confirmed that the core team forgot to close the issue. We can proceed and implement distinct() for RealmResults.
@kneth @dalinaum I'll start looking into it.
@stk1m1 Great. It will require some work on the JNI level to get it done. Don't hesitate to ask if you run into trouble.
@kneth Thanks for head up!
Right now sort() is part of the OrderedRealmCollection interface, we should consider adding this here as well. This would also mean it would work on RealmList
@kneth Actually looking over our API we already have RealmQuery.distinct() and RealmResults.distinct(). So no entirely sure what https://github.com/realm/realm-java/issues/1568#issue-110661663 is about. It is pretty old, so perhaps the title/description just need an update?
@cmelchior this was added in 0.88.0
RealmQuery.distinct() and RealmResults.distinct() (#1568).
RealmQuery.distinctAsync() and RealmResults.distinctAsync() (#2118).
RealmResults.distinct() has been deprecated, since the API is quite ambiguous -- distinct() will always create a new RealmResults instead of distinct on the original one.
This means, if you want to do distinct on a RealmResults/RealmList, you should:
realmResults.where().distinct();
realmList.where().distinct();