You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(postgrest): add casts, JSON paths and aggregates as column expressions - #2114
Step 5 of SDK-2765, port of supabase-flutter #1797 and #1798. Closes SDK-2988.
json_text(), json_text_at(), json_object(), json_object_at() on JSON columns return a JsonPath, which filters, orders and has is_null(). Operands of a -> path are sent as JSON.
cast(sql_type, value_type), sum(), avg(), min(), max(), count() and DerivedExpression.count_all() return a select-only DerivedExpression, so filtering or ordering on one is a type error. A cast of a cast and an aggregate of an aggregate raise ValueError.
select_only() takes any Expression. JSON paths and derived expressions are aliased to their own expression (shortened past 63 bytes like Dart) and PartialRow reads them by response_key. min()/max() decode as the column, sum() without its Field constraints, avg() as Decimal over Decimal.
The select list cleaner no longer strips whitespace after an escaped quote inside a quoted alias.
Test stack enables db_aggregates_enabled. Integration tests cover each new expression.
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
New Features
Added typed JSON-path access for object keys and array elements, including selection, filtering, and ordering.
Added cast and aggregate expressions, including sum, average, minimum, maximum, count, and count-all.
Selected derived values now support typed result decoding and stable response keys, including for long expressions.
Database aggregate queries are now enabled.
Bug Fixes
Improved handling of escaped quotes in selected column names.
The change adds typed JSON-path, cast, and aggregate expressions. Query selection now accepts general expressions, and selected results are looked up by response key. JSON-path filters serialize JSON operands, while casts and aggregates have typed result handling. The change also enables PostgREST aggregates for the authenticator role and adds unit, integration, and type-check coverage.
supabase/supabase-py#2044: Adds the typed query builder and typed partial-row access used by this change.
supabase/supabase-py#2043: Adds the request and executor contracts that this change extends for expression selection.
Change: Feature
Merge Risk: Minimal · up to 03cf5
This adds typed JSON-path, cast, and aggregate expressions to the PostgREST client, with tests covering rendering, selection, and decoding. No concrete merge-blocking risk was identified.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0eecc0b3-f4ae-4498-940e-920970d5b797
Commits
Reviewing files that changed from the base of the PR and between ca79c71 and 03cf562.
Files selected for processing: 2
sdk-compliance.yaml
src/postgrest/src/postgrest/table_executor.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 5 of SDK-2765, port of supabase-flutter #1797 and #1798. Closes SDK-2988.
json_text(),json_text_at(),json_object(),json_object_at()on JSON columns return aJsonPath, which filters, orders and hasis_null(). Operands of a->path are sent as JSON.cast(sql_type, value_type),sum(),avg(),min(),max(),count()andDerivedExpression.count_all()return a select-onlyDerivedExpression, so filtering or ordering on one is a type error. A cast of a cast and an aggregate of an aggregate raiseValueError.select_only()takes anyExpression. JSON paths and derived expressions are aliased to their own expression (shortened past 63 bytes like Dart) andPartialRowreads them byresponse_key.min()/max()decode as the column,sum()without itsFieldconstraints,avg()asDecimaloverDecimal.db_aggregates_enabled. Integration tests cover each new expression.