-
Notifications
You must be signed in to change notification settings - Fork 803
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
Override columns returned by functions #3614
Comments
Thanks for posting this issue. Your question helped me to figure out my issue. |
The same issue seems to happen for simple generated columns like this SELECT jsonb_object_agg(i.id, true) as online_integrations
FROM integrations i
WHERE ... then this mapping does not apply it seems version: 2
sql:
- engine: "postgresql"
schema: "schema.sql"
queries: "./queries/"
gen:
go:
sql_package: "pgx/v5"
out: "query"
package: "query"
overrides:
- column: "*.online_integrations"
go_type: "github.com/my/test/query.OnlineIntegrationsMap" with the type just being type OnlineIntegrationsMap map[string]bool also the docs only mention the |
The configuration may look like this, try this. If issue still persist share the sqlc playground link with your sql script and configurations. |
But wouldn't this config change the type for ALL jsonb columns? |
Yes I think so, try to use Postgres Domain for this particular field and specify the name of the Domain in the configuration with the type.
Try this I am not sure. |
What do you want to change?
Ability to override selected columns from postgres function to Go structs.
Current implementation
Let's say we have the following table:
And let's say
additional_info
is mapped to this Go struct:To override the type
additional_info
, we would do the following:Then when we select the column, it will be successfully mapped to the struct.
Scenario
But what if I have a postgres function that looks like this:
And the query looks like this:
The generated Go code will be:
Issue
Is it possible to map the
info
column that is returned from the function toUserInfo
struct either by specifying the type in the query itself or insqlc.yaml
config file?What database engines need to be changed?
PostgreSQL
What programming language backends need to be changed?
Go
The text was updated successfully, but these errors were encountered: