Skip to content
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

go_struct_tag is ignored for type override #3563

Open
eduardomosko opened this issue Aug 28, 2024 · 1 comment · May be fixed by #3564
Open

go_struct_tag is ignored for type override #3563

eduardomosko opened this issue Aug 28, 2024 · 1 comment · May be fixed by #3564

Comments

@eduardomosko
Copy link

eduardomosko commented Aug 28, 2024

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

@eduardomosko
Copy link
Author

There seems to already be a PR addressing this issue: #3287 but I could take a look and try to simplify it

@eduardomosko eduardomosko linked a pull request Aug 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant