Open
Description
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