-
Notifications
You must be signed in to change notification settings - Fork 268
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
base: develop
Are you sure you want to change the base?
Changes from all commits
045334b
570e54c
36d4ab4
fc7b1e7
b8aa560
fc4919a
da972ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -27,7 +27,7 @@ const ( | |||||||||||||
SwiftInternalAccessControl = "internal" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang string, schemas []string, postgrestV9Compat bool, swiftAccessControl string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { | ||||||||||||||
func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang string, schemas []string, postgrestV9Compat bool, postgrestVersion string, swiftAccessControl string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { | ||||||||||||||
originalURL := utils.ToPostgresURL(dbConfig) | ||||||||||||||
// Add default schemas if --schema flag is not specified | ||||||||||||||
if len(schemas) == 0 { | ||||||||||||||
|
@@ -60,6 +60,9 @@ func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang str | |||||||||||||
return err | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// Extract version from image tag and trim 'v' prefix | ||||||||||||||
postgrestVersion = strings.TrimPrefix(utils.Config.Api.Image, "postgrest/postgrest:v") | ||||||||||||||
|
||||||||||||||
Comment on lines
+63
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||
if strings.Contains(utils.Config.Api.Image, "v9") { | ||||||||||||||
postgrestV9Compat = true | ||||||||||||||
} | ||||||||||||||
|
@@ -94,6 +97,7 @@ func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang str | |||||||||||||
"PG_META_GENERATE_TYPES_INCLUDED_SCHEMAS=" + included, | ||||||||||||||
"PG_META_GENERATE_TYPES_SWIFT_ACCESS_CONTROL=" + swiftAccessControl, | ||||||||||||||
fmt.Sprintf("PG_META_GENERATE_TYPES_DETECT_ONE_TO_ONE_RELATIONSHIPS=%v", !postgrestV9Compat), | ||||||||||||||
fmt.Sprintf("PG_META_POSTGREST_VERSION=%s", postgrestVersion), | ||||||||||||||
}, | ||||||||||||||
Cmd: []string{"node", "dist/server/server.js"}, | ||||||||||||||
}, | ||||||||||||||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 🤔