@haathie/pgmb 0.2.1 → 0.2.3

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 +4 -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.3",
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
@@ -429,6 +429,7 @@ BEGIN
429
429
  ) THEN
430
430
  CREATE ROLE pgmb_reader NOLOGIN NOSUPERUSER NOCREATEDB
431
431
  NOCREATEROLE NOINHERIT NOREPLICATION;
432
+ GRANT pgmb_reader TO CURRENT_USER;
432
433
  END IF;
433
434
  END
434
435
  $$;
@@ -903,8 +904,7 @@ BEGIN
903
904
  emit := TRUE;
904
905
  RETURN;
905
906
  END
906
- $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE
907
- SECURITY INVOKER;
907
+ $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE SECURITY INVOKER;
908
908
 
909
909
  -- Trigger that pushes changes to the events table
910
910
  CREATE OR REPLACE FUNCTION push_table_event()
@@ -938,7 +938,7 @@ BEGIN
938
938
  SELECT
939
939
  create_event_id(clock_timestamp(), rand := start_num + n.rn),
940
940
  create_topic(TG_TABLE_SCHEMA, TG_TABLE_NAME, TG_OP),
941
- jsonb_strip_nulls(jsonb_diff(n.data, o.data)),
941
+ jsonb_diff(n.data, o.data),
942
942
  jsonb_build_object('old', jsonb_strip_nulls(o.data))
943
943
  FROM (
944
944
  SELECT s.data, s.emit, row_number() OVER () AS rn
@@ -952,7 +952,7 @@ BEGIN
952
952
  serialise_record_for_event(TG_RELID, TG_OP, o) AS s(data, emit)
953
953
  ) AS o ON n.rn = o.rn
954
954
  -- ignore rows where data didn't change
955
- WHERE n.data IS DISTINCT FROM o.data AND n.emit;
955
+ WHERE jsonb_diff(n.data, o.data) is not null AND n.emit;
956
956
  END IF;
957
957
 
958
958
  RETURN NULL;