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 """;