sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Type inference for custom types silently fails

Open DavidS-ovm opened this issue 1 year ago • 0 comments

Version

1.25.0

What happened?

See the following playground:

CREATE TYPE "public"."risk_progress_milestone" AS (
    status "public"."change_risk_status",
    message text
);
CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text,
  "risk_progress" public.risk_progress_milestone [] NOT NULL
);

is generated as

type Author struct {
	ID           int64
	Name         string
	Bio          sql.NullString
	RiskProgress []string
}

which is not what I expected.

It would be great if sqlc could correctly infer the type for RiskProgress as a nested struct of (change_risk_status, text)

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/b307e2084562bc2c64c6a2d8d55935ecb757be9223234bceb3e6941a379b07cd

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

DavidS-ovm avatar Feb 19 '24 09:02 DavidS-ovm