From 247ffe29ada1f30fba840baf2922d762d8c767b4 Mon Sep 17 00:00:00 2001 From: Mariya_Russakova Date: Thu, 25 Jan 2024 16:41:53 +0600 Subject: [PATCH] MODAUD-180 updates sql --- .../folio/dao/acquisition/impl/PieceEventsDaoImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod-audit-server/src/main/java/org/folio/dao/acquisition/impl/PieceEventsDaoImpl.java b/mod-audit-server/src/main/java/org/folio/dao/acquisition/impl/PieceEventsDaoImpl.java index 3982e4e..cc1fd4a 100644 --- a/mod-audit-server/src/main/java/org/folio/dao/acquisition/impl/PieceEventsDaoImpl.java +++ b/mod-audit-server/src/main/java/org/folio/dao/acquisition/impl/PieceEventsDaoImpl.java @@ -40,16 +40,16 @@ public class PieceEventsDaoImpl implements PieceEventsDao { private static final String GET_STATUS_CHANGE_HISTORY_BY_PIECE_ID_SQL = """ WITH StatusChanges AS ( SELECT id, action, piece_id, user_id, event_date, action_date, modified_content_snapshot, - COALESCE(LAG(modified_content_snapshot ->> 'receivingStatus') OVER w, '') AS previous_status, - COALESCE(LAG(modified_content_snapshot ->> 'claimingInterval') OVER w, '') AS previous_claiming_interval + LAG(modified_content_snapshot ->> 'receivingStatus') OVER w AS previous_status, + LAG(modified_content_snapshot ->> 'claimingInterval') OVER w AS previous_claiming_interval FROM %s WHERE piece_id=$1 WINDOW w AS (PARTITION BY piece_id ORDER BY action_date) ) SELECT id, action, piece_id, user_id, event_date, action_date, modified_content_snapshot FROM StatusChanges - WHERE modified_content_snapshot ->> 'receivingStatus' <> previous_status - OR modified_content_snapshot ->> 'claimingInterval' <> previous_claiming_interval + WHERE modified_content_snapshot ->> 'receivingStatus' IS DISTINCT FROM previous_status + OR modified_content_snapshot ->> 'claimingInterval' IS DISTINCT FROM previous_claiming_interval %s LIMIT $2 OFFSET $3 """;