Skip to content

feat: Add filters on the realtime subscriptions - #4

Open
ivasilov wants to merge 2 commits into
mainfrom
feat/realtime-with-filter
Open

feat: Add filters on the realtime subscriptions#4
ivasilov wants to merge 2 commits into
mainfrom
feat/realtime-with-filter

Conversation

@ivasilov

@ivasilov ivasilov commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds Realtime postgres_changes filters derived from each active query's WHERE clause, so a subscribed table only receives rows relevant to the queries currently observing it (falling back to an unfiltered/catch-all subscription when a query's conditions can't be expressed as Realtime filters).
  • Supports eq, neq, gt/gte/lt/lte (and their negations), in/not in, isNull/not isNull, and ANDed composite conditions, with PostgREST-safe value serialization (quoting, escaping) shared between the Realtime filter builder and the query builder.
  • Fixes a race between the initial PostgREST fetch and Realtime events: INSERT/UPDATE now upsert into the collection instead of throwing when a row arrives out of the expected order.
  • Adds an unfiltered UPDATE listener (so a row already in the collection keeps receiving updates after it stops matching a filter) and an unfiltered DELETE listener (Realtime only sends filtered deletes for tables with replica identity full).
  • Channel subscriptions are now rotated/namespaced by topic instead of a fixed per-table name, and swapped in only after the replacement channel finishes subscribing, so no change is missed during a filter-set change.

Test plan

  • pnpm test — 169 tests pass
  • pnpm build — builds cleanly

@ivasilov
ivasilov force-pushed the feat/realtime-with-filter branch from 1cc92d5 to 3d598fd Compare August 28, 2026 06:53
@ivasilov
ivasilov force-pushed the feat/realtime-with-filter branch from 3d598fd to 2e17006 Compare September 6, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants