1222: Ignore existing primary key r=Kerollmops a=MarinPostma

fixing bug in #1176 made it an hard error to try to re-set the primary key on a document addition. This PR makes Meilisearch ignore a primary key passed as an argument to a document addition. This has been decided after a discussion with @curquiza, in order to make the bug fix non breaking.

Turns out it was a good catch too, since contrary to what I thought the error was not caught asynchronously, thank you @curquiza 

Co-authored-by: mpostma <postma.marin@protonmail.com>
This commit is contained in:
bors[bot] 2021-02-04 08:08:09 +00:00 committed by GitHub
commit cb50781d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,7 +175,6 @@ async fn update_multiple_documents(
.ok_or(meilisearch_core::Error::SchemaMissing)?; .ok_or(meilisearch_core::Error::SchemaMissing)?;
match (params.into_inner().primary_key, schema.primary_key()) { match (params.into_inner().primary_key, schema.primary_key()) {
(Some(_), Some(_)) => return Err(meilisearch_schema::Error::PrimaryKeyAlreadyPresent)?,
(Some(key), None) => document_addition.set_primary_key(key), (Some(key), None) => document_addition.set_primary_key(key),
(None, None) => { (None, None) => {
let key = body let key = body
@ -184,7 +183,7 @@ async fn update_multiple_documents(
.ok_or(meilisearch_core::Error::MissingPrimaryKey)?; .ok_or(meilisearch_core::Error::MissingPrimaryKey)?;
document_addition.set_primary_key(key); document_addition.set_primary_key(key);
} }
(None, Some(_)) => () _ => ()
} }
for document in body.into_inner() { for document in body.into_inner() {