Skip to content

feat(types): setup postgrest-13 types inference #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

avallete
Copy link
Member

@avallete avallete commented May 19, 2025

What kind of change does this PR introduce?

This lay out the ground basis to start introducing new postgrest-13 features to the client library.

  1. It adds a way to opt-in via an option new PostgrestClient(DB_URL, { postgrestVersion: 12 | 13 }> allowing the types inference to pick in and choose the right result based on the available features for this major version.
  2. Add a second test container running postgrest-13 to make sure we keep consistency between runtime/typing behavior.
  3. Implement the new postgrest13 Spread on Many Relationship behavior in inference.
  4. Upgrade the workflows ubuntu versions to repair the CI/CD pipeline due to ubuntu 20 deprecation.

Comment on lines 448 to 449
? ClientOptions['postgrestVersion'] extends 13 // Spread over an many-to-many relationship, turn all the result fields into arrays
? ProcessManyToManySpreadNodeResult<Result>
Copy link
Member Author

Choose a reason for hiding this comment

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

note

Here is what the conditionality for the inference can look like.

Comment on lines +5 to 20
rest13:
image: postgrest/postgrest:v13.0.0
ports:
- '3001:3000'
environment:
PGRST_DB_URI: postgres://postgres:postgres@db:5432/postgres
PGRST_DB_SCHEMAS: public,personal
PGRST_DB_EXTRA_SEARCH_PATH: extensions
PGRST_DB_ANON_ROLE: postgres
PGRST_DB_PLAN_ENABLED: 1
PGRST_DB_TX_END: commit-allow-override
PGRST_DB_AGGREGATES_ENABLED: true
depends_on:
- db
rest12:
image: postgrest/postgrest:v12.2.0
Copy link
Member Author

Choose a reason for hiding this comment

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

note

It is also possible to check if all the current tests and the new version ones are matching by upgrading the rest12 container to postgrest:v13. I did so for testing, and except from the Spread on Many feature, everything was behaving the same, with the only difference being the returned error message within some of the inline snapshots.

@avallete avallete requested a review from soedirgo May 19, 2025 07:35
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