Skip to content

fix(postgrest-typegen): infer nullability on PostgreSQL 14 - #355

Merged
spydon merged 2 commits into
mainfrom
fix/postgrest-typegen-pg13-prosqlbody
Nov 12, 2026
Merged

spydon merged 2 commits into
mainfrom
fix/postgrest-typegen-pg13-prosqlbody

Conversation

@spydon

@spydon spydon commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

The Supabase CLI is dropping PostgreSQL 13, which makes 14 the oldest version introspect() has to support. On 14, view column nullability and RETURNS TABLE column nullability inferred nothing: PostgreSQL 14 writes range table entries as RTE in its node trees, where 15 and later write RANGETBLENTRY, and the walk only accepted the latter. Every view column and every RETURNS TABLE column on a PostgreSQL 14 database was therefore generated as nullable. The walk now accepts both names, and on 14 the full test fixture produces exactly the same output as on 15.

To keep the minimum supported version working, the parity test now runs on PostgreSQL 14 (MINIMUM_POSTGRES_VERSION) as well as 15, against the same golden files. A query that reads a catalog column added after 14, or any other difference in what 14 produces, fails every pull request. The view and RETURNS TABLE nullability suites include 14 too. Without the fix, 11 tests fail on 14; with it, the full suite passes. The README has a new "Supported PostgreSQL versions" section that names the minimum and where it is enforced.

Generated output on PostgreSQL 15 and later is unchanged.

Context: supabase/cli#7585 (comment) found that 0.8.0 fails on PostgreSQL 13, because it reads pg_proc.prosqlbody, which exists from 14. With 13 no longer supported, that query stays as it is.

@spydon
spydon requested a review from a team as a code owner November 12, 2026 09:06
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with older PostgreSQL versions when retrieving function results.
  • Tests
    • Expanded function nullability coverage across PostgreSQL 13, 15, 17, and 18, with version-specific checks for atomic function bodies.

The function result query reads prosqlbody through a JSON lookup instead of referencing the catalog column directly. Integration tests now include PostgreSQL 13 alongside PostgreSQL 15, 17, and 18. Shared function fixtures run on all tested versions, while BEGIN ATOMIC fixtures and nullability tests run only on versions marked as supporting atomic bodies.

Possibly related PRs

  • supabase/sdk#338: Adds the function result query and integration test that this change updates.

Change: Bug fix

Merge Risk: Minimal · up to 375d7

This change makes nullability inference on PostgreSQL 14 match PostgreSQL 15, and output on PostgreSQL 15 and later is unchanged. No merge-blocking issues were 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed0d1e36-c351-450c-acbd-e34a6be8baa0
Commits

Reviewing files that changed from the base of the PR and between 4a2ef38 and 375d7e1.

Files selected for processing: 6

  • packages/postgrest-typegen/CLAUDE.md
  • packages/postgrest-typegen/README.md
  • packages/postgrest-typegen/src/introspection/view-nullability.ts
  • packages/postgrest-typegen/test/introspection/function-result-nullability.test.ts
  • packages/postgrest-typegen/test/introspection/view-nullability.test.ts
  • packages/postgrest-typegen/test/parity/parity.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@spydon
spydon force-pushed the fix/postgrest-typegen-pg13-prosqlbody branch from 231e8e8 to 4a2ef38 Compare November 12, 2026 09:06
PostgreSQL 14 names range table entries RTE in its node trees where later
versions write RANGETBLENTRY, so the query tree walk proved nothing there
and every view and RETURNS TABLE column came out nullable. The walk now
accepts both, and the parity goldens run on PostgreSQL 14, the oldest
version the Supabase CLI accepts, as well as on 15.
@spydon spydon changed the title fix(postgrest-typegen): introspect PostgreSQL 13 again fix(postgrest-typegen): infer nullability on PostgreSQL 14 Nov 12, 2026
@spydon
spydon force-pushed the fix/postgrest-typegen-pg13-prosqlbody branch from 18f64d6 to 0f5bf71 Compare November 12, 2026 09:33
Comment thread packages/postgrest-typegen/README.md Resolved

@yannbf yannbf left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

@spydon
spydon merged commit 35647c3 into main Nov 12, 2026
6 checks passed
@spydon
spydon deleted the fix/postgrest-typegen-pg13-prosqlbody branch November 12, 2026 12:21
spydon pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.8.1](postgrest-typegen/v0.8.0...postgrest-typegen/v0.8.1)
(2026-11-12)


### Bug Fixes

* **postgrest-typegen:** infer nullability on PostgreSQL 14
([#355](#355))
([35647c3](35647c3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
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.

2 participants