Skip to content

go_struct_tag is ignored for type override #3563

@eduardomosko

Description

@eduardomosko

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:

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!"`
}

Relevant log output

No response

Database schema

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text,
  bio2 text
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = $1 LIMIT 1;

Configuration

{
  "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!\""
            }
          ]
        }
      }
    }
  ]
}

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions