@haathie/pgmb 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sql/pgmb.sql +3 -4
package/package.json
CHANGED
package/sql/pgmb.sql
CHANGED
|
@@ -903,8 +903,7 @@ BEGIN
|
|
|
903
903
|
emit := TRUE;
|
|
904
904
|
RETURN;
|
|
905
905
|
END
|
|
906
|
-
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE
|
|
907
|
-
SECURITY INVOKER;
|
|
906
|
+
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE SECURITY INVOKER;
|
|
908
907
|
|
|
909
908
|
-- Trigger that pushes changes to the events table
|
|
910
909
|
CREATE OR REPLACE FUNCTION push_table_event()
|
|
@@ -938,7 +937,7 @@ BEGIN
|
|
|
938
937
|
SELECT
|
|
939
938
|
create_event_id(clock_timestamp(), rand := start_num + n.rn),
|
|
940
939
|
create_topic(TG_TABLE_SCHEMA, TG_TABLE_NAME, TG_OP),
|
|
941
|
-
|
|
940
|
+
jsonb_diff(n.data, o.data),
|
|
942
941
|
jsonb_build_object('old', jsonb_strip_nulls(o.data))
|
|
943
942
|
FROM (
|
|
944
943
|
SELECT s.data, s.emit, row_number() OVER () AS rn
|
|
@@ -952,7 +951,7 @@ BEGIN
|
|
|
952
951
|
serialise_record_for_event(TG_RELID, TG_OP, o) AS s(data, emit)
|
|
953
952
|
) AS o ON n.rn = o.rn
|
|
954
953
|
-- ignore rows where data didn't change
|
|
955
|
-
WHERE n.data
|
|
954
|
+
WHERE jsonb_diff(n.data, o.data) is not null AND n.emit;
|
|
956
955
|
END IF;
|
|
957
956
|
|
|
958
957
|
RETURN NULL;
|