mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 12:42:50 +08:00
Don't validate the id field.
This commit is contained in:
parent
184ed43727
commit
614f7a9f61
@ -311,6 +311,10 @@ Option<uint32_t> Index::validate_index_in_memory(nlohmann::json& document, uint3
|
||||
const std::string& field_name = field_pair.first;
|
||||
const field& a_field = field_pair.second;
|
||||
|
||||
if(field_name == "id") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if((a_field.optional || op == UPDATE) && document.count(field_name) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -294,6 +294,24 @@ TEST_F(CollectionSpecificTest, PrefixWithTypos2) {
|
||||
collectionManager.drop_collection("coll1");
|
||||
}
|
||||
|
||||
TEST_F(CollectionSpecificTest, ImportDocumentWithIntegerID) {
|
||||
std::vector<field> fields = {field("title", field_types::STRING, false),
|
||||
field("points", field_types::INT32, false),};
|
||||
|
||||
Collection* coll1 = collectionManager.create_collection("coll1", 1, fields, "points").get();
|
||||
|
||||
nlohmann::json doc1;
|
||||
doc1["id"] = 100;
|
||||
doc1["title"] = "East India House on Wednesday evening";
|
||||
doc1["points"] = 100;
|
||||
|
||||
auto add_op = coll1->add(doc1.dump());
|
||||
ASSERT_FALSE(add_op.ok());
|
||||
ASSERT_EQ("Document's `id` field should be a string.", add_op.error());
|
||||
|
||||
collectionManager.drop_collection("coll1");
|
||||
}
|
||||
|
||||
TEST_F(CollectionSpecificTest, CreateManyCollectionsAndDeleteOneOfThem) {
|
||||
std::vector<field> fields = {field("title", field_types::STRING, false),
|
||||
field("points", field_types::INT32, false),};
|
||||
|
Loading…
x
Reference in New Issue
Block a user