Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query regression when upgrading to latest core #6850

Closed
rorbech opened this issue Aug 1, 2023 · 2 comments · Fixed by #6867
Closed

Query regression when upgrading to latest core #6850

rorbech opened this issue Aug 1, 2023 · 2 comments · Fixed by #6867
Assignees

Comments

@rorbech
Copy link
Contributor

rorbech commented Aug 1, 2023

Bumping realm-java to latest core in realm/realm-java#7837 one of the query test fails. I have isolated the failing query into a separate test and traced the new behavior to originate from d861035

The specific assertion that now fails is in https://github.com/realm/realm-java/pull/7837/files#diff-6301796adc65d635adbd23145c98bfc7828db7ed740a2265aaa89496cc2d4168R579. Before the above commit the query returns two objects while it returns three after the update.

Core version: d861035

@nirinchev
Copy link
Member

This may be related to #6831

@jedelbo jedelbo self-assigned this Aug 7, 2023
@rorbech
Copy link
Contributor Author

rorbech commented Aug 7, 2023

I have tried to cut the model down to the essential properties. So basically having:

  • Three object, all with an empty dictionary property
  • Two of them referencing an object in their children-list-property
    The query "@links.TestClass.children.dictionary.@size == 0" returns 3 elements but returned 2 before including this commit
public class TestClass extends RealmObject {
        @PrimaryKey
        public long id;

        public RealmList<io.realm.entities.TestClass> children;
        public RealmDictionary<io.realm.entities.TestClass> dictionary;
}

@Test
public void coreQueryRegression() {
        realm.beginTransaction();

        TestClass o1 = new TestClass();
        o1.id = 1L;
        TestClass o1Managed = realm.copyToRealm(o1);

        TestClass o2 = new TestClass();
        o2.id = 2L;
        o2.children = new RealmList<>(o1Managed);

        TestClass o2managed = realm.copyToRealmOrUpdate(o2);

        TestClass o3 = new TestClass();
        o3.id = 3L;
        o3.children = new RealmList<>(o2managed);
        realm.copyToRealm(o3);

        realm.commitTransaction();

        RealmResults<TestClass> all = realm.where(TestClass.class).findAll();
        assertEquals(3, all.size());

        RealmQuery<TestClass> empty = realm.where(TestClass.class)
                .rawPredicate("@links.TestClass.children.dictionary.@size == 0");

        assertEquals(2, empty.count()); // Test fails as the above query matches all the entities
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants