From 1f488cd7e94d6a7f47ddcb27772c56a2fa046c2d Mon Sep 17 00:00:00 2001 From: Azizbek Khushvakov Date: Thu, 21 Nov 2024 19:47:48 +0500 Subject: [PATCH] Update sql query --- .../migration/extract_credits_from_expenditures.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql b/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql index 4b18f8f0..5a5cf588 100644 --- a/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql +++ b/src/main/resources/templates/db_scripts/migration/extract_credits_from_expenditures.sql @@ -40,14 +40,11 @@ WITH aggregated_amounts AS ( ) UPDATE ${myuniversity}_${mymodule}.transaction AS encumbrance SET - jsonb = jsonb_set( - jsonb_set( - encumbrance.jsonb, - '{encumbrance,amountExpended}', - to_jsonb(aggregated_amounts.total_expended) - ), - '{encumbrance,amountCredited}', - to_jsonb(aggregated_amounts.total_credited) + jsonb = jsonb || jsonb_build_object( + 'encumbrance', jsonb_build_object( + 'amountExpended', to_jsonb(aggregated_amounts.total_expended), + 'amountCredited', to_jsonb(aggregated_amounts.total_credited) + ) ) FROM aggregated_amounts WHERE encumbrance.id = aggregated_amounts.encumbrance_id;