Skip to content

bug if column and param share the same name #4354

@canvasbushi

Description

@canvasbushi

Version

1.30.0

What happened?

A bug happened!
sql:

-- name: GetUserByEmail :one
SELECT email
FROM users
WHERE email = sqlc.arg(email);

generated:

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (string, error) {
	row := q.db.QueryRow(ctx, getUserByEmail, email)
	err := row.Scan(&email)
	return email, err
}

on ErrNoRows, the function GetUserByEmail returns the input email... expected an empty string.
maybe create a separate string var like what is done with other types? after a little testing, this only happens when the names are the same xD

Relevant log output

Database schema

SQL queries

Configuration

Playground URL

No response

What operating system are you using?

Windows

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 working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions