Skip to content

Overrides do not work on multiple instances of type. #3823

Closed
@thezachdrake

Description

@thezachdrake

Version

1.28.0

What happened?

I want to replace all pgtype.UUID with the more standard uuid.UUID to make these models a tad easier to work with in logic. I have the override declared in yaml. However, it only replaces the first instance of pgtype.UUID. This happens on multiple tables.

type SphinxSnakeCustomer struct {
	ID         uuid.UUID
	CreatedAt  pgtype.Timestamptz
	UpdatedAt  pgtype.Timestamptz
	Provider   pgtype.Text
	ProviderID pgtype.Text
	FirstName  pgtype.Text
	LastName   pgtype.Text
	Email      pgtype.Text
	Phone      pgtype.Text
	Postal     pgtype.Text
	Country    pgtype.Text
	FirstSeen  pgtype.Timestamptz
	LastSeen   pgtype.Timestamptz
	OrgID      pgtype.UUID
}

Relevant log output

Database schema

CREATE SCHEMA IF NOT EXISTS sphinx_snake;
CREATE TABLE IF NOT EXISTS sphinx_snake.customers (
    id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
    created_at timestamp with time zone NOT NULL DEFAULT now(),
    updated_at timestamp with time zone NOT NULL DEFAULT now(),
    provider text,
    provider_id text,
    first_name text,
    last_name text,
    email text,
    phone text,
    postal text,
    country text,
    first_seen timestamp with time zone,
    last_seen timestamp with time zone,
    org_id uuid REFERENCES orgs(id)
);
CREATE UNIQUE INDEX IF NOT EXISTS provider_customer ON sphinx_snake.customers(org_id, provider, provider_id);

SQL queries

Configuration

version: "2"
sql:
 - engine: "postgresql"
   queries: "../database/sphinx_snake/*.sql"
   schema: "../database/*sphinx*"
   gen:
     go:
       package: "sphinxsnake"
       out: "db/sphinx_snake"
       sql_package: "pgx/v5"
       overrides:
       - db_type: "uuid"
         go_type:
           import: "github.com/google/uuid"
           type: "UUID"
       - db_type: "uuid"
         go_type:
           import: "github.com/google/uuid"
           type: "UUID"

Playground URL

No response

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