Cata
Cata

Reputation: 11211

Fetch all objects having a specific empty RealmList property

Today I moved to Realm 0.83 and it is nice that we have null support but I have a problem.

I want to fetch all the stores that have empty products list inside. So far it worked if I used isNull() on the RealmQuery but since the update I get a crash like: Illegal Argument: RealmList is not nullable.

As it states in the crash, I cannot do this anymore because a RealmList is a Required field from now on so it can't be empty.. ok, that is nice but what can I use on the RealmQuery to fetch the models that I want?

Thank you!

Upvotes: 1

Views: 982

Answers (2)

whlk
whlk

Reputation: 15635

The issue has been resolved by realm. You can now use isEmpty and isNotEmpty in the query builder for all RealmList properties.

Upvotes: 4

Christian Melchior
Christian Melchior

Reputation: 20126

Unfortunately, there is no option for doing that exact query anymore in 0.83.0. We think the improved isNull semantics are better, but it is very unfortunate that it is breaking current behaviour. I have created an issue for adding support back for this and hope to have it resolved very soon: https://github.com/realm/realm-java/issues/1601.

Right now you will have to work around it by manually iterating your data to find all objects that match your criteria.

Upvotes: 3

Related Questions