Skip to content
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

sqlc generates invalid code for inserts returning * when query_parameter_limit > 2 #2678

Closed
andrewmbenton opened this issue Aug 30, 2023 · 3 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@andrewmbenton
Copy link
Collaborator

Version

1.20.0

What happened?

The insert query function is missing a variable to scan into when query_parameter_limit > 2. It appears that the number of query parameters must also be > 2 but <= query_parameter_limit to trigger the invalid codegen.

See the playground link for an example.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

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

What operating system are you using?

No response

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@andrewmbenton andrewmbenton added bug Something isn't working triage New issues that hasn't been reviewed labels Aug 30, 2023
@orisano
Copy link
Contributor

orisano commented Aug 30, 2023

Seems to be working fine (HEAD).

my local:

func (q *Queries) CreateAuthor(ctx context.Context, iD int64, name string, bio sql.NullString) (Author, error) {
	row := q.db.QueryRowContext(ctx, createAuthor, iD, name, bio)
	var i Author
	err := row.Scan(&i.ID, &i.Name, &i.Bio)
	return i, err
}

@kyleconroy
Copy link
Collaborator

I think there was a PR that recently fixed this. I merged it yesterday or Monday.

@orisano
Copy link
Contributor

orisano commented Aug 30, 2023

#2578

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

3 participants