I am getting a crash due to a java.lang.UnsupportedOperationException: Syntax error
while executing such query:
public RealmResults<MyObject> getMyObjects(List<Integer> ids, boolean filter) {
Realm realm = null;
try {
realm = Realm.getDefaultInstance();
RealmQuery<MyObject> query = realm.where(MyObject.class);
query = query.beginGroup();
for (int i=0; i< ids.size(); i++) {
query = query.equalTo("id", ids.get(i));
if (i != ids.size() -1) {
query = query.or();
}
}
query = query.endGroup();
if (filter) {
query = query.equalTo("someBoolean", true);
}
return query.findAll();
} finally {
if (realm != null) realm.close();
}
}
Removing the query = query.beginGroup();
and query = query.endGroup();
makes the syntax error go away but I'm not sure if the query will yield the same results.
Can somebody help me pointing out where the syntax error is and why it happens?