Skip to content

go_struct_tag is missing for generated result row struct (or how to configure it) #1867

Closed
@avucic

Description

@avucic

Version

1.15.0

What happened?

When I use given configuration I can see generated tag in models file.

type Account struct {
	ID          uuid.UUID `sometagtype:"some_value"`
	State       sql.NullString
       # ... rest of the fields
}

However generated struct for my query doesn't contain mentioned tag;

type FindAccountByEmailRow struct {
	ID           uuid.UUID
	State        sql.NullString
       # ... rest of the fields
}

When I use option: emit_json_tags: true I can see json tag in both places

So my question is if this is a problem or if the generator needs to be configured differently.

Relevant log output

No response

Database schema

CREATE TABLE public.accounts (
    id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    state character varying,
);

SQL queries

-- name: FindAccountByEmail :one
SELECT
    c.id AS credential_id,
    a.*,
    u.first_name,
    u.last_name,
    -- other fields
FROM
    accounts a
    INNER JOIN users_accounts ua ON a.id = ua.account_id
    INNER JOIN users u ON ua.user_id = u.id
    INNER JOIN credentials c ON c.account_id = a.id
WHERE
    c.email = @email;

Configuration

version: "2"
sql:
  - schema: "db/structure.sql"
    queries: "db/queries.sql"
    engine: "postgresql"
    gen:
      go:
        package: "db"
        out: "db"
        overrides:
          - column: accounts.id
            go_struct_tag: sometagtype:"some_value"

Playground URL

No response

What operating system are you using?

macOS

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