Skip to content

Compile error if function with single argument also returns it #1235

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
gwenaskell opened this issue Oct 13, 2021 · 0 comments
Closed

Compile error if function with single argument also returns it #1235

gwenaskell opened this issue Oct 13, 2021 · 0 comments
Labels
bug Something isn't working 🔧 golang

Comments

@gwenaskell
Copy link

Version

1.10.0

What happened?

I juste noticed a small bug on functions that take a single argument which is also returned, for example:

-- name: UpdateTable :one
UPDATE
  my_table
SET
  field1 = CURRENT_TIMESTAMP
WHERE
  id = $1
RETURNING id;

(The purpose of this being to return an error if the update does not affect a row, but there might be some other use cases)

This produces the following function:

func (q *Queries) UpdateTable(ctx context.Context, id int64) (int64, error) {
	row := q.queryRow(ctx, q.updateTableStmt, updateTable, id)
	var id int64
	err := row.Scan(&id)
	return id, err
}

which fails to compile because id is declared twice.

This is a minor bug though, since we can use named parameters instead.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@gwenaskell gwenaskell added bug Something isn't working triage New issues that hasn't been reviewed labels Oct 13, 2021
@kyleconroy kyleconroy added 🔧 golang and removed triage New issues that hasn't been reviewed labels Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🔧 golang
Projects
None yet
Development

No branches or pull requests

2 participants