Index foo_sequence_id field that stores sequence_id of referenced document.

This commit is contained in:
Harpreet Sangar 2023-01-17 09:49:17 +05:30 committed by ozanarmagan
parent 297409f105
commit 249294a657
2 changed files with 12 additions and 0 deletions

View File

@ -697,6 +697,13 @@ Option<bool> field::json_field_to_field(bool enable_nested_fields, nlohmann::jso
field_json[fields::reference])
);
if (!field_json[fields::reference].get<std::string>().empty()) {
the_fields.emplace_back(
field(field_json[fields::name].get<std::string>() + "_sequence_id", "string", false,
false, true)
);
}
return Option<bool>(true);
}

View File

@ -92,5 +92,10 @@ TEST_F(CollectionJoinTest, SchemaReferenceField) {
ASSERT_EQ(schema.at("customer_name").reference, "");
ASSERT_EQ(schema.at("product_id").reference, "Products.product_id");
ASSERT_EQ(schema.count("product_id_sequence_id"), 1);
auto field = schema.at("product_id_sequence_id");
ASSERT_TRUE(field.index);
collectionManager.drop_collection("Customers");
}