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

Support sorting by property in child object

Open snotyak opened this issue 11 years ago • 18 comments

Example:

Using the classes below:

public class TypeA extends RealmObject {
   private String name;
}

public class TypeB extends RealmObject {
    private int number;
    private TypeA someType;
}

I can't perform:

Realm realm = Realm.getInstance(this);
RealmQuery<TypeB> query = realm.where(TypeB.class);
query.findAll().sort("someType.name"); // Throws java.lang.IllegalArgumentException: Field 'someType.name' does not exist.

snotyak avatar Jan 02 '15 23:01 snotyak

Hi @snotyak Thank you for a detailed bug report. That feature is currently not supported, but the error message isn't very precise. I have updated the error message to be more clear until we can add support for this.

cmelchior avatar Jan 05 '15 08:01 cmelchior

+1

RobertoArtiles avatar May 13 '15 00:05 RobertoArtiles

:+1:

fuwaneko avatar Jun 19 '15 16:06 fuwaneko

+1

lukcz avatar Jun 28 '15 14:06 lukcz

@cmelchior I see that the exception you threw in the merge above is no longer a part of master. Has this been fixed?

snotyak avatar Jun 29 '15 14:06 snotyak

:+1:

psyren89 avatar Sep 21 '15 02:09 psyren89

Hello, do you have any ETA on this feature. it will be life saving ! Thanks a lot.

dator-zz avatar Nov 13 '15 17:11 dator-zz

+1

mateusgrb avatar Dec 21 '15 20:12 mateusgrb

+1 Query filtering works well with subproperties, so it would make sense that sorting can be used in conjuction.

guillermomuntaner avatar Dec 24 '15 19:12 guillermomuntaner

hey guys, this is solved?

heitorpr avatar Jan 14 '16 11:01 heitorpr

+1 I'm trying to implement a RecyclerView backed by a realmResults that is capable to group and sort by any of the properties of the base class, creating a "sectionedAdapter" on the fly. If I want to group by any of the related RealmObject of the base RealmObject, I also need to order the list by the same property hence the need of sort by child. Also I'm using retrolambda and Java 8 streams that make the code very clean and straightforward, however, as I can't make RealmObject implement "IComparable" I'm also stuck there: If I transform the RealmResults into a list to overcome the sorted by child, I need to make the child Icomparable, but I can't...

gpulido avatar Feb 14 '16 18:02 gpulido

:+1:

AlokBansal8 avatar Feb 15 '16 19:02 AlokBansal8

+1

tgbarker avatar Feb 16 '16 08:02 tgbarker

any updates here? :+1:

SergeyTrukhachev avatar Mar 01 '16 08:03 SergeyTrukhachev

+1

maasad avatar May 21 '16 08:05 maasad

It has been more than a year and 4 months and still no update on the feature.

AlokBansal8 avatar May 21 '16 17:05 AlokBansal8

+1

mmlii avatar Jun 02 '16 05:06 mmlii

This is a duplicate of #672, so moving all the +1's from here to there and closing this as an duplicate.

cmelchior avatar Jun 02 '16 07:06 cmelchior