Skip to content

Commit 6728a18

Browse files
authored
Fix regression and update tests (#7616)
Fixes b4e1075
1 parent 108a376 commit 6728a18

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* 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))
2020
* 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)).
2121
* 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).
22+
* Queries using query paths on Mixed values returns inconsistent results ([#7587](https://github.com/realm/realm-core/issues/7587), since v14.0.0)
2223

2324
### Breaking changes
2425
* The following things have been renamed or moved as part of moving all of the App Services functionality to the app namespace:

src/realm/query_expression.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@ class Columns<Mixed> : public SimpleQuerySupport<Mixed> {
20762076
}
20772077
}
20782078
if (!index.set_size(m_ctrl.matches.size())) {
2079-
dest.init(true, 0);
2079+
destination.init(true, 0);
20802080
return;
20812081
}
20822082
}

test/test_query2.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5630,6 +5630,51 @@ TEST_TYPES(Query_Mixed, std::true_type, std::false_type)
56305630
CHECK_EQUAL(tv.size(), 1);
56315631
}
56325632

5633+
TEST(Query_NestedListNull)
5634+
{
5635+
SHARED_GROUP_TEST_PATH(path);
5636+
auto hist = make_in_realm_history();
5637+
DBRef db = DB::create(*hist, path);
5638+
auto tr = db->start_write();
5639+
auto foo = tr->add_table("foo");
5640+
auto col_any = foo->add_column(type_Mixed, "mixed");
5641+
5642+
const char* listOfListOfNull = R"([[null]])";
5643+
5644+
foo->create_object().set_json(col_any, R"("not a list")");
5645+
foo->create_object().set_json(col_any, listOfListOfNull);
5646+
foo->create_object().set_json(col_any, listOfListOfNull);
5647+
foo->create_object().set_json(col_any, listOfListOfNull);
5648+
5649+
CHECK_EQUAL(foo->query("mixed[0][0] == null").count(), 3);
5650+
CHECK_EQUAL(foo->query("mixed[0][5] == null").count(), 0);
5651+
CHECK_EQUAL(foo->query("mixed[0][*] == null").count(), 3);
5652+
}
5653+
5654+
TEST(Query_NestedDictionaryNull)
5655+
{
5656+
SHARED_GROUP_TEST_PATH(path);
5657+
auto hist = make_in_realm_history();
5658+
DBRef db = DB::create(*hist, path);
5659+
auto tr = db->start_write();
5660+
auto foo = tr->add_table("foo");
5661+
auto col_any = foo->add_column(type_Mixed, "mixed");
5662+
5663+
const char* dictOfDictOfNull = R"({ "nestedDict": { "nullValue": null }})";
5664+
5665+
foo->create_object().set_json(col_any, R"("not a dictionary")");
5666+
foo->create_object().set_json(col_any, dictOfDictOfNull);
5667+
foo->create_object().set_json(col_any, dictOfDictOfNull);
5668+
foo->create_object().set_json(col_any, dictOfDictOfNull);
5669+
5670+
CHECK_EQUAL(foo->query("mixed['nestedDict']['nullValue'] == null").count(), 3);
5671+
CHECK_EQUAL(foo->query("mixed.nestedDict.nullValue == null").count(), 3);
5672+
CHECK_EQUAL(foo->query("mixed['nestedDict']['foo'] == null").count(), 3);
5673+
CHECK_EQUAL(foo->query("mixed.nestedDict.foo == null").count(), 3);
5674+
CHECK_EQUAL(foo->query("mixed.nestedDict[*] == null").count(), 3);
5675+
CHECK_EQUAL(foo->query("mixed.nestedDict[*].@type == 'null'").count(), 3);
5676+
}
5677+
56335678
TEST(Query_ListOfMixed)
56345679
{
56355680
Group g;

0 commit comments

Comments
 (0)