sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Generation of required params struct is missing for CopyFrom query when using query_parameter_limit

Open renier opened this issue 1 year ago • 2 comments

Version

1.25.0

What happened?

sqlc is not generating the params struct necessary for a copy-from query when your configuration specifies query_parameter_limit. This is on version 1.25.0. Works fine if you remove query_parameter_limit from the configuration.

Relevant log output

No response

Database schema

CREATE TABLE IF NOT EXISTS alert_triage_status (
  id varchar(512) primary key,
  assignee varchar(512)
);

SQL queries

-- name: AddAssigneeToAlertTriageStatuses :copyfrom
INSERT INTO alert_triage_status (id, assignee) VALUES ($1, $2);

-- name: RemoveAssigneeFromAlertsTriageStatuses :exec
DELETE FROM alert_triage_status WHERE assignee = $1 AND id = ANY($2::varchar[]);

Configuration

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

Playground URL

https://play.sqlc.dev/p/90e29f89bd6b6be43c83c31794eb5d80fb753a3c26250f077353c081ad3433ea

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

renier avatar Feb 14 '24 02:02 renier

Running into the same issue. CopyFrom should trigger the struct to be generated regardless if it is necessary for calling the other query functions.

ysmilda avatar Jun 18 '24 13:06 ysmilda

Seems to be a duplicate from https://github.com/sqlc-dev/sqlc/issues/3443 and it has been fixed.

ysmilda avatar Jun 18 '24 14:06 ysmilda