@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sql/pgmb.sql +3 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haathie/pgmb",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "PG message broker, with a type-safe typescript client with built-in webhook & SSE support.",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {
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
- jsonb_strip_nulls(jsonb_diff(n.data, o.data)),
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 IS DISTINCT FROM o.data AND n.emit;
954
+ WHERE jsonb_diff(n.data, o.data) is not null AND n.emit;
956
955
  END IF;
957
956
 
958
957
  RETURN NULL;