Repository navigation
feat: support more realtime filters and multiple filters for stream - #1610
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChangesRealtime stream filtering
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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Caution Review failedAn 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. Comment |
46c42c4 to
a109e61
Compare
a109e61 to
8700298
Compare
8700298 to
72ed101
Compare
|
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 |
There was a problem hiding this comment.
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 winInconsistent compliance additions: some stream filters missing
SupabaseStreamFilterBuildersymbols.
eq,like,ilike,isFilter/isDistinct,match/imatchall got aSupabaseStreamFilterBuilder.*symbol added alongside the existingPostgrestFilterBuildermapping, butneq,gt,gte,lt,lte, andinFilter— all of which were reworked in the same PR (packages/supabase/lib/src/supabase_stream_filter_builder.dartlines 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.inFilterAlso 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
📒 Files selected for processing (8)
.github/workflows/test.ymlpackages/supabase/dart_test.yamlpackages/supabase/lib/src/supabase_query_builder.dartpackages/supabase/lib/src/supabase_stream_builder.dartpackages/supabase/lib/src/supabase_stream_filter_builder.dartpackages/supabase/test/stream_integration_test.dartsdk-compliance.yamlsupabase/migrations/20240101000000_postgrest_schema.sql
There was a problem hiding this comment.
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 supportlike,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 betweengtandgte, 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.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
…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 -->
…#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 -->
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?
streamdid not catch up with newly supported realtime filters likelike,ilike,match,imatch,isDistinctWhat is the new behavior?
streammethod by mentioning two realtime caveats affecting the behavior of the stream methodI'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
stream()calls using AND semantics.like,ilike,match,imatch,isFilter, andisDistinct.public.userstable.