Documentation leads me to believe that setting a listener type ("UPDATE" or "INSERT") on postgres_changes would scope the data sent to the client to the event listener type.
However, when specifying a listen type it seems that ALL events on the table are sent via websocket to the client.
Note: The callback produces the correctly scoped result.
To Reproduce
Given the following table (with realtime enabled and RLS turned off):
create table
public.test_realtime (
id bigint generated by default as identity not null,
data text null,
created_at timestamp with time zone null default now(),
constraint test_realtime_pkey primary key (id)
) tablespace pg_default;
{"topic":"realtime:testing_postgres","event":"phx_join","payload":{"config":{"broadcast":{"ack":false,"self":false},"presence":{"key":""},"postgres_changes":[{"event":"UPDATE","schema":"public","table":"test_realtime"}]}},"ref":"1","join_ref":"1"}
{"event":"phx_reply","payload":{"response":{"postgres_changes":[{"id":46046838,"event":"UPDATE","schema":"public","table":"test_realtime"}]},"status":"ok"},"ref":"1","topic":"realtime:testing_postgres"}
{"event":"presence_state","payload":{},"ref":null,"topic":"realtime:testing_postgres"}
{"event":"system","payload":{"channel":"testing_postgres","extension":"postgres_changes","message":"Subscribed to PostgreSQL","status":"ok"},"ref":null,"topic":"realtime:testing_postgres"}
{"event":"postgres_changes","payload":{"data":{"columns":[{"name":"id","type":"int8"},{"name":"data","type":"text"},{"name":"created_at","type":"timestamptz"}],"commit_timestamp":"2023-04-28T02:20:36.979Z","errors":null,"record":{"created_at":"2023-04-28T02:20:36.978014+00:00","data":"New Data inserted at 9:20:36 PM","id":62},"schema":"public","table":"test_realtime","type":"INSERT"},"ids":[46046838]},"ref":null,"topic":"realtime:testing_postgres"}
{"event":"postgres_changes","payload":{"data":{"columns":[{"name":"id","type":"int8"},{"name":"data","type":"text"},{"name":"created_at","type":"timestamptz"}],"commit_timestamp":"2023-04-28T02:20:37.175Z","errors":null,"old_record":{"id":62},"record":{"created_at":"2023-04-28T02:20:36.978014+00:00","data":"New Data updated at: 9:20:37 PM","id":62},"schema":"public","table":"test_realtime","type":"UPDATE"},"ids":[46046838]},"ref":null,"topic":"realtime:testing_postgres"}
{"event":"postgres_changes","payload":{"data":{"columns":[{"name":"id","type":"int8"},{"name":"data","type":"text"},{"name":"created_at","type":"timestamptz"}],"commit_timestamp":"2023-04-28T02:20:37.301Z","errors":null,"old_record":{"id":62},"schema":"public","table":"test_realtime","type":"DELETE"},"ids":[46046838]},"ref":null,"topic":"realtime:testing_postgres"}
And the following console logs:
Called from UPDATE: {
"schema": "public",
"table": "test_realtime",
"commit_timestamp": "2023-04-28T02:20:37.175Z",
"eventType": "UPDATE",
"new": {
"created_at": "2023-04-28T02:20:36.978014+00:00",
"data": "New Data updated at: 9:20:37 PM",
"id": 62
},
"old": {
"id": 62
},
"errors": null
}
Expected behavior
Websocket logs should not show events of type DELETE or INSERT when subscribed only to UPDATEs
System information
OS: Windows/Mac
Browser (if applies): Chrome
Version of supabase-js: 2.21.0
Version of Node.js: v18.14.0
Additional context
Also in reference to supabase-community/realtime-csharp#27
Bug report
Describe the bug
Documentation leads me to believe that setting a listener type ("UPDATE" or "INSERT") on
postgres_changes
would scope the data sent to the client to the event listener type.However, when specifying a listen type it seems that ALL events on the table are sent via websocket to the client. Note: The callback produces the correctly scoped result.
To Reproduce
Given the following table (with realtime enabled and RLS turned off):
And using the following code:
Produces the following websocket logs:
And the following console logs:
Expected behavior
Websocket logs should not show events of type DELETE or INSERT when subscribed only to UPDATEs
System information
Additional context
Also in reference to supabase-community/realtime-csharp#27