Return 409 status code when document with given ID already exists.

This commit is contained in:
Kishore Nallan 2018-01-27 08:47:28 -05:00
parent 85f9887a2f
commit c16513005b
2 changed files with 2 additions and 2 deletions

View File

@ -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);

View File

@ -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");