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

query_parameter_limit breaks batchexec queries #3185

Closed
SoMuchForSubtlety opened this issue Feb 6, 2024 · 1 comment · Fixed by #3300
Closed

query_parameter_limit breaks batchexec queries #3185

SoMuchForSubtlety opened this issue Feb 6, 2024 · 1 comment · Fixed by #3300
Labels
Milestone

Comments

@SoMuchForSubtlety
Copy link
Contributor

Version

1.25.0

What happened?

If the number of parameters for a batchexec is ≤ query_parameter_limit, the struct for the parameters does not get generated.

The generated function still tries to use the missing struct, and thus does not compile.

Relevant log output

No response

Database schema

CREATE TABLE authors (
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: CreateAuthors :batchexec
INSERT INTO authors (
  name, bio
) VALUES (
  $1, $2
);

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "postgresql",
    "gen": {
      "go": {
        "out": "db",
        "sql_package": "pgx/v5",
        "query_parameter_limit": 2
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/2741cf608de5f3ea978a6feef8e2cf094a3d3dad9c8b0230e4a0e3039132b16b

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@SoMuchForSubtlety SoMuchForSubtlety added bug Something isn't working triage New issues that hasn't been reviewed labels Feb 6, 2024
@SoMuchForSubtlety SoMuchForSubtlety changed the title Can break query_parameter_limit breaks batchexec queries query_parameter_limit breaks batchexec queries Feb 7, 2024
@kyleconroy kyleconroy added 📚 postgresql and removed triage New issues that hasn't been reviewed labels Mar 4, 2024
@kyleconroy kyleconroy added this to the 1.26.0 milestone Mar 4, 2024
@urandom
Copy link

urandom commented Aug 6, 2024

Hi @kyleconroy

It seems there is another bug with the batchexec. It's visible in the linked playground in the description. The generated batch.go file imports "github.com/jackc/pgx/v5/pgtype" which is never referenced, which causes a compilation error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants