Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Add test for null value + update of missing optional field.

Kishore Nallanbeb95a659aee
diff --git a/test/collection_specific_more_test.cpp b/test/collection_specific_more_test.cpp
index f53ce1a7..e3f82f69 100644
--- a/test/collection_specific_more_test.cpp
+++ b/test/collection_specific_more_test.cpp
@@ -1311,6 +1311,21 @@ TEST_F(CollectionSpecificMoreTest, UpdateArrayWithNullValue) {
auto results = coll1->search("alpha", {"tags"}, "", {}, {}, {0}, 10, 1, FREQUENCY, {false}).get();
ASSERT_EQ(0, results["found"].get<size_t>());
+ // update document with no value (optional field) with a null value
+ auto doc3 = R"({
+ "id": "2"
+ })"_json;
+
+ ASSERT_TRUE(coll1->add(doc3.dump(), CREATE).ok());
+ results = coll1->search("alpha", {"tags"}, "", {}, {}, {0}, 10, 1, FREQUENCY, {false}).get();
+ ASSERT_EQ(0, results["found"].get<size_t>());
+
+ doc_update = R"({
+ "id": "2",
+ "tags": null
+ })"_json;
+ ASSERT_TRUE(coll1->add(doc_update.dump(), UPDATE).ok());
+
// via upsert
doc_update = R"({