Skip to content

feat(typegen): non-null view columns from postgrest-typegen 0.6.0 - #1968

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2251-view-column-nullability
Oct 16, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2251-view-column-nullability

Conversation

@spydon

@spydon spydon commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What

@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.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: supabase/supabase-flutter/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac07202d-2329-4437-8a9d-7477a4cbc5dc
📥 Commits

Reviewing files that changed from the base of the PR and between 35f6cff and a654659.

📒 Files selected for processing: 5
  • packages/supabase_typegen/lib/src/generator_metadata_parser.dart
  • packages/supabase_typegen/test/fixtures/generator_metadata.json
  • packages/supabase_typegen/test/generator_metadata_parser_test.dart
  • packages/supabase_typegen/test/goldens/hostile_schema.dart
  • packages/supabase_typegen/test/goldens/supabase_schema.dart

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.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: androidpoet

Merge Risk: 🔵 Low · up to a6546

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: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: support for non-null view columns based on postgrest-typegen 0.6.0 metadata.
Docstring Coverage Passed 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 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.
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.

❤️ Share

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

@spydon
spydon merged commit c9f89d5 into main Oct 16, 2026
27 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2251-view-column-nullability branch October 16, 2026 12:46
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.

1 participant