mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
adding primary-key when adding documents does not work; fix #519
This commit is contained in:
parent
4ccf1d10bd
commit
ce0e8415d5
4 changed files with 54 additions and 24 deletions
|
@ -118,9 +118,9 @@ fn find_primary_key(document: &IndexMap<String, Value>) -> Option<String> {
|
|||
}
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
struct UpdateDocumentsQuery {
|
||||
document_id: Option<String>,
|
||||
primary_key: Option<String>,
|
||||
}
|
||||
|
||||
async fn update_multiple_documents(mut ctx: Request<Data>, is_partial: bool) -> SResult<Response> {
|
||||
|
@ -141,7 +141,7 @@ async fn update_multiple_documents(mut ctx: Request<Data>, is_partial: bool) ->
|
|||
.ok_or(ResponseError::internal("schema not found"))?;
|
||||
|
||||
if schema.primary_key().is_none() {
|
||||
let id = match query.document_id {
|
||||
let id = match query.primary_key {
|
||||
Some(id) => id,
|
||||
None => match data.first().and_then(|docs| find_primary_key(docs)) {
|
||||
Some(id) => id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue