sqlc
sqlc copied to clipboard
Renaming doesn't apply to JSON tags
Version
1.24.0
What happened?
When using the rename configuration, the JSON tags that are generated are not renamed.
Look at the playground example, the output Struct is:
type Author struct {
TheIdentifier int64 `json:"id"`
EsteemedTitle string `json:"name"`
Biography sql.NullString `json:"bio"`
}
I would have expected:
type Author struct {
TheIdentifier int64 `json:"TheIdentifier"`
EsteemedTitle string `json:"EsteemedTitle"`
Biography sql.NullString `json:"Biography"`
}
Sidenote: I realize that I could just not emit JSON tags, and the resulting JSON string would be according to my expectations, however that falls down when combined with json_tags_case_style: camel for example.
Relevant log output
No response
Database schema
CREATE TABLE authors (
id BIGSERIAL PRIMARY KEY,
name text NOT NULL,
bio text
);
SQL queries
No response
Configuration
{
"version": "2",
"sql": [{
"schema": "schema.sql",
"queries": "query.sql",
"engine": "postgresql",
"gen": {
"go": {
"out": "db",
"emit_json_tags": true,
"rename": {
"name": "EsteemedTitle",
"id": "TheIdentifier",
"bio": "Biography"
}
}
}
}]
}
Playground URL
https://play.sqlc.dev/p/c1cd74708ccee0e69b462b062629edd5567d0d3dfd491b7a60c08291c8ec63d9
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go