mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
fix bad error report when primary key exists
This commit is contained in:
parent
944a3943e5
commit
ced6cc0e23
@ -253,17 +253,8 @@ async fn update_index(
|
|||||||
|
|
||||||
if let Some(id) = body.primary_key.clone() {
|
if let Some(id) = body.primary_key.clone() {
|
||||||
if let Some(mut schema) = index.main.schema(writer)? {
|
if let Some(mut schema) = index.main.schema(writer)? {
|
||||||
match schema.primary_key() {
|
schema.set_primary_key(&id)?;
|
||||||
Some(_) => {
|
index.main.put_schema(writer, &schema)?;
|
||||||
return Err(Error::bad_request(
|
|
||||||
"The primary key cannot be updated",
|
|
||||||
).into());
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
schema.set_primary_key(&id)?;
|
|
||||||
index.main.put_schema(writer, &schema)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index.main.put_updated_at(writer)?;
|
index.main.put_updated_at(writer)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user