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

Column type overrides lost when renaming a parameter #1864

Closed
haines opened this issue Sep 27, 2022 · 1 comment · Fixed by #1884
Closed

Column type overrides lost when renaming a parameter #1864

haines opened this issue Sep 27, 2022 · 1 comment · Fixed by #1884

Comments

@haines
Copy link
Contributor

haines commented Sep 27, 2022

Version

1.15.0

What happened?

When a type override is defined for a column, it only applies to parameters if they are positional or named the same as the column itself.

In the example below, I expected to generate

func (q *Queries) Renamed(ctx context.Context, userEmail user.Email) (user.ID, error)

but with a named parameter I got

func (q *Queries) Renamed(ctx context.Context, userEmail string) (user.ID, error)

unless the parameter was named email (which matches the inferred name, so isn't very useful!).

Relevant log output

No response

Database schema

CREATE TABLE users (
  id bigserial PRIMARY KEY,
  email text NOT NULL CONSTRAINT unique_email UNIQUE
);

SQL queries

-- name: Renamed :one
SELECT id
FROM users
WHERE email = @user_email;

Configuration

{
  "version": "2",
  "sql": [
    {
      "engine": "postgresql",
      "schema": "query.sql",
      "queries": "query.sql",
      "gen": {
        "go": {
          "out": "db",
          "overrides": [
            {
              "column": "users.id",
              "go_type": "example.com/user.ID"
            },
            {
              "column": "users.email",
              "go_type": "example.com/user.Email"
            }
          ]
        }
      }
    }
  ]
}

Playground URL

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

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@haines haines added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 27, 2022
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang 💻 darwin and removed triage New issues that hasn't been reviewed labels Nov 9, 2022
@haines
Copy link
Contributor Author

haines commented Nov 30, 2022

Previously reported in #606 and #1752, so I'm going to close this.

@haines haines closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2022
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.

2 participants