Skip to content

Overlapping input and output variables in Go #1290

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
benfdking opened this issue Nov 16, 2021 · 0 comments
Closed

Overlapping input and output variables in Go #1290

benfdking opened this issue Nov 16, 2021 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@benfdking
Copy link

benfdking commented Nov 16, 2021

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

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

2 participants