From 5e3670a00800495ba76fe7c3537b807725335617 Mon Sep 17 00:00:00 2001 From: Florian Goessler Date: Wed, 8 Jan 2025 12:25:39 +0100 Subject: [PATCH] refactor: remove unwrap --- .../sql-query-connector/src/database/operations/write.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/query-engine/connectors/sql-query-connector/src/database/operations/write.rs b/query-engine/connectors/sql-query-connector/src/database/operations/write.rs index 37fba8854da..1afa8aea8b8 100644 --- a/query-engine/connectors/sql-query-connector/src/database/operations/write.rs +++ b/query-engine/connectors/sql-query-connector/src/database/operations/write.rs @@ -460,11 +460,12 @@ pub(crate) async fn delete_records( write::delete_many_from_ids_and_filter(model, ids.as_slice(), filter_condition, remaining_limit, ctx) { row_count += conn.execute(delete).await?; - if let Some(limit) = remaining_limit { - remaining_limit = Some(limit - row_count as i64); - if remaining_limit.unwrap() <= 0 { + if let Some(old_remaining_limit) = remaining_limit { + let new_remaining_limit = old_remaining_limit - row_count as i64; + if new_remaining_limit <= 0 { break; } + remaining_limit = Some(new_remaining_limit); } } row_count