From c202f3dbe2c7b6d00c9dc217bf768695bd0c3004 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 18 Nov 2024 10:13:04 +0100 Subject: [PATCH] fix tests and revert change in behavior when primary_key_from_op != primary_key_from_db && index.is_empty() --- crates/index-scheduler/src/lib.rs | 2 +- crates/milli/src/update/new/indexer/mod.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/index-scheduler/src/lib.rs b/crates/index-scheduler/src/lib.rs index 83431d45c..df8870470 100644 --- a/crates/index-scheduler/src/lib.rs +++ b/crates/index-scheduler/src/lib.rs @@ -4601,7 +4601,7 @@ mod tests { snapshot!(primary_key.is_none(), @"false"); // The second batch should contains only one task that fails because it tries to update the primary key to `bork`. - handle.advance_one_failed_batch(); + handle.advance_one_successful_batch(); snapshot!(snapshot_index_scheduler(&index_scheduler), name: "second_task_fails"); // The third batch should succeed and only contains one task. diff --git a/crates/milli/src/update/new/indexer/mod.rs b/crates/milli/src/update/new/indexer/mod.rs index 0906c5b89..00cc2d2c1 100644 --- a/crates/milli/src/update/new/indexer/mod.rs +++ b/crates/milli/src/update/new/indexer/mod.rs @@ -777,15 +777,9 @@ pub fn retrieve_or_guess_primary_key<'a>( match primary_key_from_op { // we did, and it is different from the DB one Some(primary_key_from_op) if primary_key_from_op != primary_key_from_db => { - // is the index empty? - if index.number_of_documents(rtxn)? == 0 { - // change primary key - (primary_key_from_op, true) - } else { - return Ok(Err(UserError::PrimaryKeyCannotBeChanged( - primary_key_from_db.to_string(), - ))); - } + return Ok(Err(UserError::PrimaryKeyCannotBeChanged( + primary_key_from_db.to_string(), + ))); } _ => (primary_key_from_db, false), }