Skip to content

Duplicate variable names #1968

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

Closed
arafath-mk opened this issue Nov 27, 2022 · 2 comments
Closed

Duplicate variable names #1968

arafath-mk opened this issue Nov 27, 2022 · 2 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@arafath-mk
Copy link

Version

1.12.0

What happened?

In the generated function, there is a Go error. id redeclared in this block

There are two id variables. One in the function parameter and another in the function body.

Relevant log output

const getUserRole = `-- name: GetUserRole :one
SELECT id FROM public.user_roles
WHERE id = $1 LIMIT 1
`

func (q *Queries) GetUserRole(ctx context.Context, id int64) (int64, error) {
	row := q.db.QueryRow(ctx, getUserRole, id)
	var id int64
	err := row.Scan(&id)
	return id, err
}

Database schema

CREATE TABLE user_roles (
  id   BIGSERIAL PRIMARY KEY
);

SQL queries

-- name: GetUserRole :one
SELECT * FROM public.user_roles
WHERE id = $1 LIMIT 1;

Configuration

version: "2"
sql:
- schema: "server/database/postgres/migrate/"
  queries: "server/database/postgres/sqlc_queries/user/"
  engine: "postgresql"
  gen:
    go: 
      package: "user"
      out: "server/go/layer/repository/db/pgsql/user"
      sql_package: "pgx/v4"

Playground URL

No response

What operating system are you using?

Windows

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@arafath-mk arafath-mk added bug Something isn't working triage New issues that hasn't been reviewed labels Nov 27, 2022
@zaneli
Copy link
Contributor

zaneli commented Feb 4, 2023

Seems to fixed by #1298

@kyleconroy
Copy link
Collaborator

Duplicate of #1490

@kyleconroy kyleconroy marked this as a duplicate of #1490 Feb 22, 2023
@kyleconroy kyleconroy closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

3 participants