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

MySQL copyfrom with query_parameter_limit: 0 generates invalid go code #3443

Closed
Gardego5 opened this issue Jun 13, 2024 · 1 comment · Fixed by #3446
Closed

MySQL copyfrom with query_parameter_limit: 0 generates invalid go code #3443

Gardego5 opened this issue Jun 13, 2024 · 1 comment · Fixed by #3446
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Milestone

Comments

@Gardego5
Copy link

Version

1.26.0

What happened?

When generating a copyfrom query in mysql and setting the query_parameter_limit to 0, sqlc incorrectly generates an invalid go file, calling the (e *mysqltsv.Encoder).AppendString(s string) function with an array of structs as the argument. This code does not compile.

Relevant log output

No response

Database schema

CREATE TABLE author (
  id   BIGINT UNSIGNED PRIMARY KEY,
  name text            NOT NULL
);

SQL queries

-- name: CreateAuthors :copyfrom
INSERT INTO author
	(name)
VALUES (?);

Configuration

version: "2"
sql:
  - engine: "mysql"
    schema: "migrations/sqlc"
    queries: "queries"
    gen:
      go:
        package: "db"
        sql_package: database/sql
        sql_driver: github.com/go-sql-driver/mysql

Playground URL

https://play.sqlc.dev/p/34328b7faed42fedb392c42cbe3a6851ebce76e304fcf091fe0f81368d52273c

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

@Gardego5 Gardego5 added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 13, 2024
@terricain
Copy link
Contributor

@Gardego5 I raised a PR to fix this, if you need a quick fix, you can see the changes here: #3446

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

Successfully merging a pull request may close this issue.

3 participants