Skip to content

feat(typegen): add postgrest-version params #3602

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: develop
Choose a base branch
from

Conversation

avallete
Copy link
Member

@avallete avallete force-pushed the feat/add-postgrest-version-to-typescript-typegen branch from 31ed7fa to 045334b Compare May 22, 2025 14:38
@avallete avallete marked this pull request as ready for review July 3, 2025 09:51
@avallete avallete requested a review from a team as a code owner July 3, 2025 09:51
@coveralls
Copy link

coveralls commented Jul 7, 2025

Pull Request Test Coverage Report for Build 16189480091

Details

  • 4 of 9 (44.44%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 55.516%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/gen.go 0 5 0.0%
Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 16189105286: -0.04%
Covered Lines: 6079
Relevant Lines: 10950

💛 - Coveralls

@@ -106,6 +110,7 @@ func init() {
typeFlags.StringSliceVarP(&schema, "schema", "s", []string{}, "Comma separated list of schema to include.")
typeFlags.Var(&swiftAccessControl, "swift-access-control", "Access control for Swift generated types.")
typeFlags.BoolVar(&postgrestV9Compat, "postgrest-v9-compat", false, "Generate types compatible with PostgREST v9 and below. Only use together with --db-url.")
typeFlags.StringVar(&postgrestVersion, "postgrest-version", "", "Generate types with __InternalSupabase schema using the right version of postgrest. Only use together with --db-url.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can deprecate the v9 compat flag with this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can infer v9 automatically from the postgrestVersion. Just wonder if that might break some user commands 🤔

Comment on lines +63 to +65
// Extract version from image tag and trim 'v' prefix
postgrestVersion = strings.TrimPrefix(utils.Config.Api.Image, "postgrest/postgrest:v")

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to its own check that also applies to remote database?

Suggested change
// Extract version from image tag and trim 'v' prefix
postgrestVersion = strings.TrimPrefix(utils.Config.Api.Image, "postgrest/postgrest:v")
if len(postgrestVersion) == 0 {
// Extract version from image tag and trim 'v' prefix
postgrestVersion = strings.TrimPrefix(utils.Config.Api.Image, "postgrest/postgrest:v")
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Hum I don't get it, for remote we'll hit the api endpoint to get the type generated. We need this for local types gen only for "dev/local" databases don't we ? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

It's also possible to connect to remote db via direct connection string, via --db-url flag. Although it's more common to hit our hosted api like you mentioned.

Another use case is connecting to self hosted db that's not on localhost.

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.

3 participants