Skip to content

Code for pgx/v4 doesn't compile with same named input and output param #1490

@Jille

Description

@Jille

Version

1.12.0

What happened?

I have a query that takes id as its only input, and also returns id as its only output.

That causes the function arg and a variable to be called id, thus failing compilation.

Fascinating is that this only breaks with pgx/v4, not with database/sql. The latter seems to reuse the variable and make it work.

Relevant log output

gendb/queries.sql.go:16:6: id redeclared in this block
  gendb/queries.sql.go:14:68: previous declaration

Database schema

No response

SQL queries

INSERT INTO authors (name) SELECT name FROM authors a WHERE a.id = $1 RETURNING id;

Configuration

No response

Playground URL

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

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