Open eduardomosko opened 3 months ago
1.27.0
The config parameter go_struct_tag works as expected when overriding a column, but not when overriding a type.
go_struct_tag
With the attached config, I hoped that the generated type would be like:
type Author struct { ID int64 Name string Bio *string `type_override:"doesnt_work"` Bio2 *string `column_override:"works!"` }
but the actual type is:
type Author struct { ID int64 Name string Bio *string Bio2 *string `column_override:"works!"` }
No response
CREATE TABLE authors ( id BIGSERIAL PRIMARY KEY, name text NOT NULL, bio text, bio2 text );
-- name: GetAuthor :one SELECT * FROM authors WHERE id = $1 LIMIT 1;
{ "version": "2", "sql": [ { "schema": "schema.sql", "queries": "query.sql", "engine": "postgresql", "gen": { "go": { "out": "db", "overrides": [ { "db_type": "text", "go_type": { "type": "string", "pointer": true }, "nullable": true, "go_struct_tag": "type_override:\"doesnt_work\"" }, { "column": "authors.bio2", "go_type": { "type": "string", "pointer": true }, "nullable": true, "go_struct_tag": "column_override:\"works!\"" } ] } } } ] }
https://play.sqlc.dev/p/784492da14076cb054559e87ad78b0fdb311b7318db65b58564b8a5fa78b2469
Linux
PostgreSQL
Go
There seems to already be a PR addressing this issue: #3287 but I could take a look and try to simplify it
Version
1.27.0
What happened?
The config parameter
go_struct_tag
works as expected when overriding a column, but not when overriding a type.With the attached config, I hoped that the generated type would be like:
but the actual type is:
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/784492da14076cb054559e87ad78b0fdb311b7318db65b58564b8a5fa78b2469
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go