diff --git a/src/collection.cpp b/src/collection.cpp index 282eca0b..f658e359 100644 --- a/src/collection.cpp +++ b/src/collection.cpp @@ -349,6 +349,9 @@ Option Collection::add_reference_helper_fields(nlohmann::json& document, c filter_query += ","; } if (!filter_values_added) { + document[reference_helper_field] = nlohmann::json::array(); + document[fields::reference_helper_fields] += reference_helper_field; + continue; } filter_query[filter_query.size() - 1] = ']'; diff --git a/test/collection_join_test.cpp b/test/collection_join_test.cpp index 5e7e6b9c..1f89adea 100644 --- a/test/collection_join_test.cpp +++ b/test/collection_join_test.cpp @@ -1408,7 +1408,7 @@ TEST_F(CollectionJoinTest, JoinAfterUpdateOfArrayField) { ASSERT_EQ(1, res["hits"][0]["document"]["bodyParts"].size()); ASSERT_EQ(1, res["hits"][0]["document"]["parts"].size()); - exercise_doc["bodyParts"] = {}; + exercise_doc["bodyParts"] = nlohmann::json::array(); ASSERT_TRUE(exercise_coll->add(exercise_doc.dump(), UPDATE).ok()); req_params = {