From 0a41f9b6134431e925b6bf75f2d2e070e930a6b9 Mon Sep 17 00:00:00 2001 From: Jacek Malec Date: Fri, 20 Dec 2024 13:37:50 +0000 Subject: [PATCH] fix: correct update_one_without_selection --- .../sql-query-connector/src/database/operations/update.rs | 6 +++++- .../sql-query-connector/src/database/operations/write.rs | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/query-engine/connectors/sql-query-connector/src/database/operations/update.rs b/query-engine/connectors/sql-query-connector/src/database/operations/update.rs index d0845ed8345..4773853ea25 100644 --- a/query-engine/connectors/sql-query-connector/src/database/operations/update.rs +++ b/query-engine/connectors/sql-query-connector/src/database/operations/update.rs @@ -79,7 +79,11 @@ pub(crate) async fn update_one_without_selection( let id_args = pick_args(&model.primary_identifier().into(), &args); // Perform the update and return the ids on which we've applied the update. // Note: We are _not_ getting back the ids from the update. Either we got some ids passed from the parent operation or we perform a read _before_ doing the update. - let (_, ids) = update_many_from_ids_and_filter(conn, model, record_filter, args, None, ctx).await?; + let (updates, ids) = update_many_from_ids_and_filter(conn, model, record_filter, args, None, ctx).await?; + for update in updates { + conn.execute(update).await?; + } + // Since we could not get the ids back from the update, we need to apply in-memory transformation to the ids in case they were part of the update. // This is critical to ensure the following operations can operate on the updated ids. let merged_ids = merge_write_args(ids, id_args); 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 ed200af5822..b71fc782671 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 @@ -426,9 +426,7 @@ pub(crate) async fn update_records_returning( let meta = column_metadata::create(&field_names, &idents); let mut records = ManyRecords::new(field_names.clone()); - let updates = generate_updates(conn, model, record_filter, args, Some(&selected_fields.into()), ctx).await?; - - for update in updates { + for update in generate_updates(conn, model, record_filter, args, Some(&selected_fields.into()), ctx).await? { let result_set = conn.query(update).await?; for result_row in result_set {