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

copyfrom not respecting query_parameter_limit #3388

Open
KlemenPl opened this issue May 16, 2024 · 0 comments
Open

copyfrom not respecting query_parameter_limit #3388

KlemenPl opened this issue May 16, 2024 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@KlemenPl
Copy link

Version

1.26.0

What happened?

When using :copyfrom query with query_parameter_limit set, generated code will still try to use parameter struct:

func (q *Queries) CreateAuthors(ctx context.Context, arg []CreateAuthorsParams) (int64, error) {
	return q.db.CopyFrom(ctx, []string{"author"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg})
}

Meanwhile, if you use :one it will respect set query_parameter_limit:

func (q *Queries) CreateAuthor(ctx context.Context, name string, bio pgtype.Text) (int64, error) {
	row := q.db.QueryRow(ctx, createAuthor, name, bio)
	var id int64
	err := row.Scan(&id)
	return id, err
}

Relevant log output

No response

Database schema

CREATE TABLE author (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: CreateAuthor :one
INSERT INTO author
	(name, bio)
VALUES (@name, @bio)
RETURNING id;

-- name: CreateAuthors :copyfrom
INSERT INTO author
	(name, bio)
VALUES (@name, @bio);

Configuration

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

Playground URL

https://play.sqlc.dev/p/849ecfee7a92c0862b4e877189cb3ddd33c2b181ae1266ada98e8f25f635004f

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@KlemenPl KlemenPl added bug Something isn't working triage New issues that hasn't been reviewed labels May 16, 2024
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

1 participant