mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 04:32:38 +08:00
Return 409 status code when document with given ID already exists.
This commit is contained in:
parent
85f9887a2f
commit
c16513005b
@ -86,7 +86,7 @@ Option<nlohmann::json> Collection::add(const std::string & json_str) {
|
||||
|
||||
// we need to check if document ID already exists before attempting to index
|
||||
if(doc_option.ok()) {
|
||||
return Option<nlohmann::json>(400, std::string("A document with id ") + doc_id + " already exists.");
|
||||
return Option<nlohmann::json>(409, std::string("A document with id ") + doc_id + " already exists.");
|
||||
}
|
||||
|
||||
const Option<uint32_t> & index_memory_op = index_in_memory(document, seq_id);
|
||||
|
@ -1485,7 +1485,7 @@ TEST_F(CollectionTest, IndexingWithBadData) {
|
||||
ASSERT_TRUE(add_op.ok());
|
||||
add_op = sample_collection->add(doc);
|
||||
ASSERT_FALSE(add_op.ok());
|
||||
ASSERT_EQ(400, add_op.code());
|
||||
ASSERT_EQ(409, add_op.code());
|
||||
ASSERT_STREQ("A document with id 100 already exists.", add_op.error().c_str());
|
||||
|
||||
collectionManager.drop_collection("sample_collection");
|
||||
|
Loading…
x
Reference in New Issue
Block a user