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(typegen): non-null view columns from postgrest-typegen 0.6.0 - #1968
@supabase/postgrest-typegen 0.6.0 (bundled by typegen 0.3.1) infers view column nullability from the source column (supabase/sdk#284). A view column that passes through a NOT NULL column, outside the nullable side of an outer join, is no longer reported as nullable. This updates supabase_typegen to that document.
Changes
Regenerated test/fixtures/generator_metadata.json on a fresh postgres:15 with postgrest-typegen/v0.6.0. Eight view columns flip to non-null: author_stats.author_id, book_prices.id/title, book_summaries.id/title/author_name and book_submissions.title/author_name. Computed columns such as count(*) and price * 0.9 stay nullable. The release also marks latest_book and recent_books as not callable through /rpc (fix(postgrest-typegen): narrow the computed-field fallback and key RPC groups safely sdk#272), which changes no generated code.
View and materialized view columns are never required on insert. The catalog does not carry the base table default onto the view column, so a non-null column like book_prices.id (an identity on books) can still be omitted when inserting through the view. This matches the TypeScript generator, which makes every view Insert and Update field optional.
Regenerated the goldens: those view columns become T on the row and PostgrestColumn instead of PostgrestNullableColumn, and their setXToNull() helpers are gone.
Summary by CodeRabbit
Bug Fixes
Generated types now preserve non-nullable column information for views and materialized views, while correctly keeping view columns out of required insert fields.
Insert and update helpers no longer offer null-setting methods for columns declared non-nullable.
Generated types for tables continue to mark non-nullable columns without defaults as required for inserts.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
📝 Walkthrough
The metadata parser now distinguishes views from other relations when determining whether columns are required. Updated fixtures and generated schema snapshots reflect non-nullable column metadata and revised RPC lookup errors.
Changes: View and column nullability
Layer / File(s)
Summary
Relation classification and required-column rule packages/supabase_typegen/lib/src/generator_metadata_parser.dart, packages/supabase_typegen/test/generator_metadata_parser_test.dart
Relation metadata carries an isView flag into table construction. A non-nullable column without a default is marked required only when its relation is not a view. The test checks view-column nullability and confirms that a non-nullable view column is not required.
Metadata fixtures and generated schema snapshots packages/supabase_typegen/test/fixtures/generator_metadata.json, packages/supabase_typegen/test/goldens/*
Fixtures update column nullability and record schema-cache errors for two RPC overloads. Generated snapshots use non-nullable types and remove null-setting methods for the affected fields. The generated-file headers report version 0.5.2.
Some generated book-submissions inserts can omit values their database trigger requires, so those requests fail. Supplying the values avoids the failure; the remaining risk is bounded and mergeable with owner awareness.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly identifies the main change: support for non-null view columns based on postgrest-typegen 0.6.0 metadata.
Docstring Coverage
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (5 skipped: 5 unsupported.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
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.
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.
What
@supabase/postgrest-typegen0.6.0 (bundled bytypegen0.3.1) infers view column nullability from the source column (supabase/sdk#284). A view column that passes through aNOT NULLcolumn, outside the nullable side of an outer join, is no longer reported as nullable. This updatessupabase_typegento that document.Changes
test/fixtures/generator_metadata.jsonon a freshpostgres:15withpostgrest-typegen/v0.6.0. Eight view columns flip to non-null:author_stats.author_id,book_prices.id/title,book_summaries.id/title/author_nameandbook_submissions.title/author_name. Computed columns such ascount(*)andprice * 0.9stay nullable. The release also markslatest_bookandrecent_booksas not callable through/rpc(fix(postgrest-typegen): narrow the computed-field fallback and key RPC groups safely sdk#272), which changes no generated code.book_prices.id(an identity onbooks) can still be omitted when inserting through the view. This matches the TypeScript generator, which makes every viewInsertandUpdatefield optional.Ton the row andPostgrestColumninstead ofPostgrestNullableColumn, and theirsetXToNull()helpers are gone.Summary by CodeRabbit