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

Fix regression and update tests #7616

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fixed an issue during a subsequent open of an encrypted Realm for some rare allocation patterns when the top ref was within ~50 bytes of the end of a page. This could manifest as a DecryptionFailed exception or as an assertion: `encrypted_file_mapping.hpp:183: Assertion failed: local_ndx < m_page_state.size()`. ([#7319](https://github.com/realm/realm-core/issues/7319))
* Non-streaming download sync progress notification is fixed for flexible sync Realms where before it was sometimes stopping to emit values right after the registration of the callback (PR [#7561](https://github.com/realm/realm-core/issues/7561)).
* Schema initialization could hit an assertion failure if the sync client applied a downloaded changeset while the Realm file was in the process of being opened ([#7041](https://github.com/realm/realm-core/issues/7041), since v11.4.0).
* Queries using query paths on Mixed values returns inconsistent results ([#7587](https://github.com/realm/realm-core/issues/7587), since v14.0.0)

### Breaking changes
* The following things have been renamed or moved as part of moving all of the App Services functionality to the app namespace:
Expand Down
2 changes: 1 addition & 1 deletion src/realm/query_expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@ class Columns<Mixed> : public SimpleQuerySupport<Mixed> {
}
}
if (!index.set_size(m_ctrl.matches.size())) {
dest.init(true, 0);
destination.init(true, 0);
return;
}
}
Expand Down
45 changes: 45 additions & 0 deletions test/test_query2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5630,6 +5630,51 @@ TEST_TYPES(Query_Mixed, std::true_type, std::false_type)
CHECK_EQUAL(tv.size(), 1);
}

TEST(Query_NestedListNull)
{
SHARED_GROUP_TEST_PATH(path);
auto hist = make_in_realm_history();
DBRef db = DB::create(*hist, path);
auto tr = db->start_write();
auto foo = tr->add_table("foo");
auto col_any = foo->add_column(type_Mixed, "mixed");

const char* listOfListOfNull = R"([[null]])";

foo->create_object().set_json(col_any, R"("not a list")");
foo->create_object().set_json(col_any, listOfListOfNull);
foo->create_object().set_json(col_any, listOfListOfNull);
foo->create_object().set_json(col_any, listOfListOfNull);

CHECK_EQUAL(foo->query("mixed[0][0] == null").count(), 3);
CHECK_EQUAL(foo->query("mixed[0][5] == null").count(), 0);
CHECK_EQUAL(foo->query("mixed[0][*] == null").count(), 3);
}

TEST(Query_NestedDictionaryNull)
{
SHARED_GROUP_TEST_PATH(path);
auto hist = make_in_realm_history();
DBRef db = DB::create(*hist, path);
auto tr = db->start_write();
auto foo = tr->add_table("foo");
auto col_any = foo->add_column(type_Mixed, "mixed");

const char* dictOfDictOfNull = R"({ "nestedDict": { "nullValue": null }})";

foo->create_object().set_json(col_any, R"("not a dictionary")");
foo->create_object().set_json(col_any, dictOfDictOfNull);
foo->create_object().set_json(col_any, dictOfDictOfNull);
foo->create_object().set_json(col_any, dictOfDictOfNull);

CHECK_EQUAL(foo->query("mixed['nestedDict']['nullValue'] == null").count(), 3);
CHECK_EQUAL(foo->query("mixed.nestedDict.nullValue == null").count(), 3);
CHECK_EQUAL(foo->query("mixed['nestedDict']['foo'] == null").count(), 3);
CHECK_EQUAL(foo->query("mixed.nestedDict.foo == null").count(), 3);
CHECK_EQUAL(foo->query("mixed.nestedDict[*] == null").count(), 3);
CHECK_EQUAL(foo->query("mixed.nestedDict[*].@type == 'null'").count(), 3);
}

TEST(Query_ListOfMixed)
{
Group g;
Expand Down
Loading