Skip to content

feat: support more realtime filters and multiple filters for stream - #1610

Merged
spydon merged 12 commits into
mainfrom
feat/stream-changes
Aug 4, 2026
Merged

spydon merged 12 commits into
mainfrom
feat/stream-changes

Conversation

@Vinzent03

@Vinzent03 Vinzent03 commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

feature; catching up with newer capabilities of the realtime client for the stream method.

What is the current behavior?

  • The stream did not catch up with newly supported realtime filters like like, ilike, match, imatch, isDistinct
  • Previously realtime did only allow one filter, but that has changed and is not yet reflected in the stream method.

What is the new behavior?

  • Allow the new filters as well
  • Allow any count of filters
  • Improve documentation of the stream method by mentioning two realtime caveats affecting the behavior of the stream method

I've also added the first integration tests for the stream method. Ensuring the values are all properly serialized as well.

Additional context

This pr does not yet cover adding negated stream filters. Will add that in a future pr.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added support for combining multiple filters in real-time stream() calls using AND semantics.
    • Added stream filters including like, ilike, match, imatch, isFilter, and isDistinct.
  • Bug Fixes
    • Improved reliability of Docker-based real-time integration tests with longer timeouts.
  • Documentation
    • Expanded streaming guidance covering filtering, behavior, supported operators, and event handling.
  • Chores
    • Enabled real-time streaming updates for the public.users table.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7bc73850-5a4d-4279-9044-4aae17b151d8

📥 Commits

Reviewing files that changed from the base of the PR and between d7b242e and b7a48b6.

📒 Files selected for processing (1)
  • packages/supabase/lib/src/supabase_query_builder.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/supabase/lib/src/supabase_query_builder.dart

📝 Walkthrough

Walkthrough

Changes

Realtime stream filtering

Layer / File(s) Summary
Multi-filter stream runtime
packages/supabase/lib/src/supabase_stream_*.dart, packages/supabase/lib/src/supabase_query_builder.dart, sdk-compliance.yaml
Stream filters now accumulate multiple conditions, support additional operators, and apply all conditions to realtime subscriptions and initial PostgREST queries. Documentation and SDK capability mappings reflect the expanded API.
Realtime integration validation
supabase/migrations/..., .github/workflows/test.yml, packages/supabase/dart_test.yaml, packages/supabase/test/stream_integration_test.dart
The test users table is added to the realtime publication, Supabase is included in backend test setup, integration timeouts are extended, and stream filtering behavior is covered by integration tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SupabaseStreamFilterBuilder
  participant SupabaseStreamBuilder
  participant PostgREST
  participant Realtime
  Client->>SupabaseStreamFilterBuilder: append stream filters
  SupabaseStreamFilterBuilder->>SupabaseStreamBuilder: retain combined filters
  SupabaseStreamBuilder->>PostgREST: fetch initial filtered rows
  SupabaseStreamBuilder->>Realtime: subscribe with filtered changes
  Realtime-->>SupabaseStreamBuilder: emit matching updates
  SupabaseStreamBuilder-->>Client: deliver stream snapshots
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: added Realtime filters and support for multiple stream filters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/stream-changes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Vinzent03
Vinzent03 force-pushed the feat/stream-changes branch from 46c42c4 to a109e61 Compare July 28, 2026 02:08
@Vinzent03
Vinzent03 force-pushed the feat/stream-changes branch from a109e61 to 8700298 Compare July 28, 2026 02:12
@Vinzent03
Vinzent03 force-pushed the feat/stream-changes branch from 8700298 to 72ed101 Compare July 28, 2026 02:36
@Vinzent03

Copy link
Copy Markdown
Collaborator Author

This pr should be ready now. Adding the tests took way longer than expected to get to my liking's. I got really strange side effects of trying to use isDistinct or isFilter on list columns.
There's also a strange extra delay for the first test case, because the replication needs more time to set up on the first one. I will probably come up with another pr to better time the postgrest call and first event if the replication is actually established and not when only the channel is subscribed.

@Vinzent03
Vinzent03 marked this pull request as ready for review July 28, 2026 13:02
@Vinzent03
Vinzent03 requested a review from a team as a code owner July 28, 2026 13:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdk-compliance.yaml (1)

466-490: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Inconsistent compliance additions: some stream filters missing SupabaseStreamFilterBuilder symbols.

eq, like, ilike, isFilter/isDistinct, match/imatch all got a SupabaseStreamFilterBuilder.* symbol added alongside the existing PostgrestFilterBuilder mapping, but neq, gt, gte, lt, lte, and inFilter — all of which were reworked in the same PR (packages/supabase/lib/src/supabase_stream_filter_builder.dart lines 16-111) — were not. This under-reports SDK filter coverage for those operators.

📝 Proposed fix
   database.using_filters.neq:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.neq
+      - SupabaseStreamFilterBuilder.neq
   database.using_filters.gt:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.gt
+      - SupabaseStreamFilterBuilder.gt
   database.using_filters.gte:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.gte
+      - SupabaseStreamFilterBuilder.gte
   database.using_filters.lt:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.lt
+      - SupabaseStreamFilterBuilder.lt
   database.using_filters.lte:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.lte
+      - SupabaseStreamFilterBuilder.lte
   ...
   database.using_filters.in:
     status: implemented
     symbols:
       - PostgrestFilterBuilder.inFilter
+      - SupabaseStreamFilterBuilder.inFilter

Also applies to: 527-530

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdk-compliance.yaml` around lines 466 - 490, Update the compliance entries
for database.using_filters.neq, gt, gte, lt, lte, and inFilter to include their
corresponding SupabaseStreamFilterBuilder symbols alongside the existing
PostgrestFilterBuilder symbols. Keep the implemented status and existing
mappings unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/supabase/lib/src/supabase_query_builder.dart`:
- Around line 59-62: Update the supported-filter documentation near
SupabaseStreamFilterBuilder to include both inFilter and isFilter alongside the
existing stream filter methods, without changing implementation behavior.

In `@packages/supabase/test/stream_integration_test.dart`:
- Around line 18-33: Dispose the SupabaseClient created in setUpAll after user
seeding and replication waiting completes, ensuring the cleanup runs even if
setup fails. Keep the per-test _supabase lifecycle unchanged.

---

Outside diff comments:
In `@sdk-compliance.yaml`:
- Around line 466-490: Update the compliance entries for
database.using_filters.neq, gt, gte, lt, lte, and inFilter to include their
corresponding SupabaseStreamFilterBuilder symbols alongside the existing
PostgrestFilterBuilder symbols. Keep the implemented status and existing
mappings unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 741cde8a-efea-4e97-96c7-ce08d741ca2e

📥 Commits

Reviewing files that changed from the base of the PR and between 6979093 and 72ed101.

📒 Files selected for processing (8)
  • .github/workflows/test.yml
  • packages/supabase/dart_test.yaml
  • packages/supabase/lib/src/supabase_query_builder.dart
  • packages/supabase/lib/src/supabase_stream_builder.dart
  • packages/supabase/lib/src/supabase_stream_filter_builder.dart
  • packages/supabase/test/stream_integration_test.dart
  • sdk-compliance.yaml
  • supabase/migrations/20240101000000_postgrest_schema.sql

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the supabase Dart client’s .stream() API to match newer Realtime Postgres Changes capabilities by supporting additional operators and combining multiple filters (AND semantics), and adds integration coverage to validate filter serialization/behavior.

Changes:

  • Extend .stream() filtering to support like, ilike, match, imatch, isFilter, isDistinct, and multiple filters.
  • Apply the same filter set to both the initial PostgREST fetch and the Realtime subscription (via filters:).
  • Add Docker-backed integration tests for stream filtering and adjust CI/test timeouts to accommodate them.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
supabase/migrations/20240101000000_postgrest_schema.sql Adds public.users to the Realtime publication for stream integration coverage.
sdk-compliance.yaml Declares the new SupabaseStreamFilterBuilder filter symbols as implemented.
packages/supabase/test/stream_integration_test.dart Adds integration tests validating filter operators and multi-filter AND semantics.
packages/supabase/lib/src/supabase_stream_filter_builder.dart Adds new filter builder methods and switches to accumulating multiple filters.
packages/supabase/lib/src/supabase_stream_builder.dart Applies multiple filters to both PostgREST query building and Realtime onPostgresChanges(filters: ...).
packages/supabase/lib/src/supabase_query_builder.dart Expands .stream() documentation (with a couple of docstring formatting issues to fix).
packages/supabase/dart_test.yaml Introduces an integration tag timeout multiplier for slower Docker-backed tests.
.github/workflows/test.yml Treats the supabase package as backend-dependent so integration tests can run in CI.
Suppressed comments (1)

packages/supabase/lib/src/supabase_query_builder.dart:62

  • The list of supported .stream() filters in the docstring has a missing comma between gt and gte, and the sentence becomes hard to read. This is visible in generated docs and can confuse users about which operators are supported.
  /// `eq`, `neq`, `lt`, `lte`, `gt` `gte`, `like`, `ilike`, `match`, `imatch`,
  /// `isDistinct`, `isFilter` or `inFilter` and `order`, `limit` filter are available to limit the
  /// data being queried.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spydon
spydon merged commit 5447063 into main Aug 4, 2026
47 checks passed
@spydon
spydon deleted the feat/stream-changes branch August 4, 2026 11:32
spydon added a commit that referenced this pull request Aug 5, 2026
…ers with tests (#1639)

Follow-up to #1610.

- Renames `match` and `imatch` to `matchRegex` and `imatchRegex`.
`PostgrestFilterBuilder.match` takes a map of equality checks and maps
to a different capability, its regex filters are `matchRegex` and
`imatchRegex`, and the stream filters delegated to `query.matchRegex`
while being named `match`. Every other stream filter already mirrors the
PostgREST name. Both methods are unreleased, so no published API
changes.
- Fixes the `stream()` docs: filter list, and what the DELETE limitation
means and how `replica identity full` lifts it.
- Registers the remaining stream filters in `sdk-compliance.yaml`.
- Adds `test/stream_filter_test.dart`, which asserts what every filter
sends to realtime and to PostgREST against a mock server, so the mapping
is covered without a backend.
- Extends the integration tests to unfiltered streams, more filter
combinations, updates that stay inside, leave and enter the filter,
deletes, and `order` with `limit`.
- Makes the integration tests wait for the channel to join instead of
sleeping, warm up replication once, and settle their mutations before
the test ends.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Expanded stream filtering with comparison, membership, pattern, null,
boolean, and distinct filters.
  - Added support for ordering and limiting stream results.
  - Renamed regex filters to `matchRegex` and `imatchRegex`.
  - Multiple stream filters are now combined with `AND`.

- **Documentation**
- Clarified delete behavior, replica identity requirements, supported
filters, and usage examples.

- **Tests**
- Added comprehensive coverage for filter serialization, combined
filters, updates, deletes, ordering, and limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
spydon added a commit that referenced this pull request Oct 5, 2026
…#1909)

## What kind of change does this PR introduce?

Feature. Brings the remaining parts of the Realtime server's [Postgres
Changes filters and column
selection](https://supabase.com/blog/postgres-changes-filters-and-column-selection)
to `stream()`, on the untyped and the typed surface.

Closes #338. Several AND-combined filters and the new operators already
reached `stream()` in #1610, and `RealtimeChannel.onPostgresChanges`
already takes `filters`, `select` and `PostgresChangeFilter.negate`.

## What is the current behavior?

- `stream()` cannot negate a filter: there is no `not` on
`SupabaseStreamFilterBuilder`, and the typed `filter()` rejects
`Books.status.inFilter([...]).not()` because
`PostgrestFilter.comparison` is `null` for a negated node.
- `stream()` always selects `*` from PostgREST and receives full rows
over Realtime; `select` cannot be passed through.

## What is the new behavior?

- `SupabaseStreamFilterBuilder.not(column, type, value)` sends
`column=not.<op>.value` to Realtime and `column=not.<op>.value` to
PostgREST, combined with the other filters as before.
- `PostgrestComparison.negated` reports a `not()` around a single
comparison, so the typed `filter()` accepts `Books.status.eq('x').not()`
and forwards it the same way. Composed filters (`&`, `|`) are still
rejected.
- `stream(primaryKey: [...], select: [...])` restricts the initial
snapshot and every change payload to the listed columns. The primary key
columns are always added, since the stream matches change payloads to
rows by them.
- The typed `streamOnly(primaryKey: [...], columns: [...])` mirrors
`selectOnly` and resolves to `List<PostgrestPartialRow<Row>>`, so a
column that was left out cannot be read by mistake. For that,
`SupabaseTypedStreamBuilder` and `SupabaseTypedStreamFilterBuilder` gain
an `Element` type parameter next to `Row`, the way the postgrest typed
builders carry `Result`. The typed surface is `@experimental`.
- `PostgrestPartialRow.fromSelections` is an `@internal` entry point for
building partial rows from change payloads.

## Tests

- `stream_filter_test.dart` asserts the wire format of negated filters
and of `select` on both surfaces, and that composed filters are still
rejected.
- `stream_select_test.dart` streams partial rows through the mock
transport and reads them through the selected columns.
- `stream_integration_test.dart` runs `not`, `not inFilter` and column
selection against the local stack (realtime v2.129.3 honours `select`).
- `postgrest_filter_test.dart` covers `PostgrestComparison.negated`.

New public symbols are registered in `sdk-compliance.yaml`; the symbol,
drift and schema checks pass locally.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Stream subscriptions can select specific columns. Primary-key columns
are included automatically, and ordering columns are included when
needed. Typed streams also support partial rows; unselected columns are
unavailable.
* Stream filters support negation, including equality, list-membership,
and null filters. Negated filters apply to both the initial query and
realtime updates. Composed filters remain unsupported for stream
filtering.
* **Bug Fixes**
* Invalid stream filter values and empty typed column selections now
produce clear argument errors.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants