Skip to content

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

Closed
@gwenaskell

Description

@gwenaskell

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions