Skip to content

Commit

Permalink
Fix using stringops query on nested collections
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Feb 6, 2024
1 parent 5c36732 commit 05f73f6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Changes to inner collections will not be reported by notifier on owning collection ([#7270](https://github.com/realm/realm-core/issues/7270), since 14.0.0-beta.0)
* @count/@size not supported for mixed properties ([#7280](https://github.com/realm/realm-core/issues/7280), since v10.0.0)
* Query with @type does not support filtering on collections ([#7281](https://github.com/realm/realm-core/issues/7281), since 14.0.0-beta.0)
* Query involving string operations on nested collections would not work ([#7282](https://github.com/realm/realm-core/issues/7282), since 14.0.0-beta.0)

### Breaking changes
* If you want to query using @type operation, you must use 'objectlink' to match links to objects. 'object' is reserved for dictionary types.
Expand Down
2 changes: 1 addition & 1 deletion src/realm/parser/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ Query StringOpsNode::visit(ParserDriver* drv)

verify_only_string_types(right_type, string_for_op(op));

if (prop && !prop->links_exist() && right->has_single_value() &&
if (prop && !prop->links_exist() && !prop->has_path() && right->has_single_value() &&
(left_type == right_type || left_type == type_Mixed)) {
auto col_key = prop->column_key();
if (right_type == type_String) {
Expand Down
2 changes: 2 additions & 0 deletions test/test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5309,9 +5309,11 @@ TEST(Parser_NestedMixedDictionaryList)
CHECK_EQUAL(q.count(), 1);

verify_query(test_context, persons, "properties.instruments[0].strings == 6", 1);
verify_query(test_context, persons, "properties.instruments[0].strings > 5", 1);
verify_query(test_context, persons, "properties.instruments[*].strings == 6", 2);
verify_query(test_context, persons, "properties.instruments[LAST].strings == 6", 1);
verify_query(test_context, persons, "properties.instruments[*].@keys == 'color'", 1);
verify_query(test_context, persons, "properties.instruments[*].brand BEGINSWITH 'gi'", 2);
verify_query(test_context, persons, "properties[*][0].legs == 2", 1); // Pipper the bird
verify_query(test_context, persons, "properties[*][0].legs == 4", 1); // Lady the cat
verify_query(test_context, persons, "properties[*][*].legs == 0", 1); // carl the snake
Expand Down

0 comments on commit 05f73f6

Please sign in to comment.