Reputation: 6486
Model:
public class Something extends RealmObject {
private String firstField;
private String secondField;
This is my query:
RealmResults<Something> r = realm.where(Something.class)
.notEqualTo("firstField","secondField")
.findAll();
is this correct and will give me all the records where the two fields are different? or will it give me all the records where firstField is not equal to the String "secondField"?
If it is incorrect, how do I achieve the comparing of the two fields?
Upvotes: 3
Views: 3754
Reputation: 20126
Christian from Realm here. It is the second option. That query will compare the field "firstField" to the string "secondField". Unfortunately there is no easy way to do what you want, but it is probably not a uncommon use case so it is something we will take a look at how to support more easily.
Currently you would have to do it by hand:
RealmResults<Something> r = realm.where(Something.class)
.notEqualTo("firstField","secondField")
.findAll();
for (Something obj : r) {
if (!obj.getFirstField().equals(obj.getSecondField())) {
// Handle object
}
}
Upvotes: 6