realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

Adding `distinct()` to RealmList

Open kneth opened this issue 11 years ago • 10 comments

For consistency, RealmQuery.distinct() and RealmResults.distinct() should be added.

kneth avatar Oct 09 '15 13:10 kneth

https://github.com/realm/realm-core/issues/1064 is still open. Should we add the Waiting-Core label again? @kneth

dalinaum avatar Jan 05 '16 09:01 dalinaum

I believe it was added to core release 0.95.4 but I will try to get it confirmed.

kneth avatar Jan 05 '16 09:01 kneth

@dalinaum Confirmed that the core team forgot to close the issue. We can proceed and implement distinct() for RealmResults.

kneth avatar Jan 05 '16 12:01 kneth

@kneth @dalinaum I'll start looking into it.

stk1m1 avatar Jan 12 '16 06:01 stk1m1

@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 avatar Jan 12 '16 07:01 kneth

@kneth Thanks for head up!

stk1m1 avatar Jan 12 '16 09:01 stk1m1

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

cmelchior avatar Jan 26 '17 11:01 cmelchior

@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 avatar Jan 26 '17 11:01 cmelchior

@cmelchior this was added in 0.88.0

RealmQuery.distinct() and RealmResults.distinct() (#1568).
RealmQuery.distinctAsync() and RealmResults.distinctAsync() (#2118).

Zhuinden avatar Jan 26 '17 11:01 Zhuinden

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();

beeender avatar Mar 24 '17 10:03 beeender