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

[Collections in mixed] Query not matching expected elements #7393

Closed
rorbech opened this issue Feb 28, 2024 · 2 comments · Fixed by #7404
Closed

[Collections in mixed] Query not matching expected elements #7393

rorbech opened this issue Feb 28, 2024 · 2 comments · Fixed by #7404
Assignees

Comments

@rorbech
Copy link
Contributor

rorbech commented Feb 28, 2024

Expected results

Given a schema:

class JsonStyleRealmObject(id: String) : RealmObject {
    @PrimaryKey
    @PersistedName("_id")
    var id: String = id
    var value: RealmAny? = null
}

and a single instance

JsonStyleRealmObject {
    id = "EMBEDDED"
    value = realmAnyListOf(
        listOf(4, 5, 6),
        mapOf(
            "key1" to 7,
            "key2" to 8,
            "key3" to listOf(9),
        )
    )
}

The following query will not match anything:

realm.query<JsonStyleRealmObject>("value[*][*] == {4, 5, 6}").find()

while the almost similar query (with explicit first index) will match the object:

realm.query<JsonStyleRealmObject>("value[0][*] == {4, 5, 6}").find()

I would expect both queries to yield the same match.

See above.

Steps & Code to Reproduce

The actual tests are in Realm Kotlin

Core version

Core version: v13.26.0-175-g5c367320a

Copy link

sync-by-unito bot commented Feb 28, 2024

➤ PM Bot commented:

Jira ticket: RCORE-1996

@jedelbo jedelbo self-assigned this Feb 28, 2024
@jedelbo
Copy link
Contributor

jedelbo commented Mar 1, 2024

This is a wider problem, not only for nested collections. Check this test case:

TEST(Parser_Wildcard)
{
    Group g; 
    auto table = g.add_table("table"); 
    auto origin = g.add_table("origin");
    auto col_list = table->add_column_list(type_Mixed, "list");
    auto col_link = origin->add_column_list(*table, "link");
    auto obj1 = table->create_object().set_json(col_list, R"([4, 5, 6])"); 
    auto obj2 = table->create_object().set_json(col_list, R"([1, 2, 3])");
    auto ll = origin->create_object().get_linklist(col_link);
    ll.add(obj1.get_key());
    ll.add(obj2.get_key());
    auto q = origin->query("link[0].list = {4, 5, 6}");
    CHECK_EQUAL(q.count(), 1); 
    q = origin->query("link.list = {4, 5, 6}");
    CHECK_EQUAL(q.count(), 1); // Fails
}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2024
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.

2 participants