Using DynamicRealm 4.3.3
A)
DynamicRealmObject lastTrack = realm.where(Model.TRACK).sort("timeStart", Sort.DESCENDING).findAll().first(null);
and
B)
DynamicRealmObject lastTrack = realm.where(Model.TRACK).sort("timeStart", Sort.DESCENDING).findFirst();
A) and B) have different results. A) is correct working, B) not working
What do you mean with "not working" ?
@cmelchior I'd assume it returns a different value than findAll().first().
exactly what @Zhuinden said
A returns the correct object, b returns an other object
Ouh this one is bad. Is this how it should work? I hope not, confused two devs for quite some time finding the cause of an bug.
There didn't use to be a findFirstSorted() so I think this is probably just an oversight.
findAll().first(null) is recommended at this time.
Sorting an indexed field and returning back the first element is mandatory for a data set. I hope there will be an acceptable solution in Realm for this. At the moment findAll().first(null) takes too long (2-3 seconds) on 300.000 instances on an Android phone. And I'm interested in a primary key here.
just spent 4 hours troubleshooting this thinking that I made a mistake somehow
Fixed by #5848
It is not working yet!
Realm version 4.3.3. @cmelchior
Well yeah it was fixed in 5.0.1, see the change log https://github.com/realm/realm-java/blob/master/CHANGELOG.md#bug-fixes-1
Most helpful comment
Well yeah it was fixed in 5.0.1, see the change log https://github.com/realm/realm-java/blob/master/CHANGELOG.md#bug-fixes-1