Skip to content

Overlapping input and output variables in Go #1290

@benfdking

Description

@benfdking

Version

1.10.0

What happened?

A bug happened! Of course, I am more than happy to help with this issue. That said, it was my first time using and I guess I broke it. Also of course not urgent as easily avoidable but would be nice for someone trying out on first time and in theory seems doable but I wouldn't want to make any assumption about a shiny tool I just love to use.

Slightly an edge case but sqlc reports uncompilable code.

const getUser = `-- name: GetUser :one
SELECT sub FROM users
WHERE sub = $1 LIMIT 1

func (q *Queries) GetUser(ctx context.Context, sub uuid.UUID) (uuid.UUID, error) {
	row := q.db.QueryRowContext(ctx, getUser, sub)
	var sub uuid.UUID
	err := row.Scan(&sub)
	return sub, err
}
`



### Relevant log output

```shell
sub redeclared in block


### Database schema

```sql
CREATE TABLE users (
  sub UUID PRIMARY KEY
)

SQL queries

SELECT sub 
FROM users
WHERE sub = $1 
LIMIT 1

Configuration

version: 1
packages:
  - path: "pkg/test"
    name: "test"
    engine: "postgresql"
    schema: "pkg/server/postgres/migrations"
    queries: "pkg/test/queries.sql"
    emit_interface: true

Playground URL

https://play.sqlc.dev/p/96f9cc7ae6630ae490cbaee0429188c3bd46e564765268f626a0fed918c397c9

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

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions