Version
1.22.0
What happened?
When using named parameters in your insert statement (@param_name or sqlc.arg(param_name)) the parameter name is used in the pgx CopyFrom method instead of the column name.
In the playground example below, the copyfrom codegen is:
func (q *Queries) StageUserData(ctx context.Context, arg []StageUserDataParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"user_data"}, []string{"id_parameter", "user_parameter"}, &iteratorForStageUserData{rows: arg})
}
but it should be
func (q *Queries) StageUserData(ctx context.Context, arg []StageUserDataParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"user_data"}, []string{"id", "user"}, &iteratorForStageUserData{rows: arg})
}
Relevant log output
No response
Database schema
create table "user_data" (
"id" varchar not null,
"user" varchar not null,
primary key ("id")
);
SQL queries
-- name: StageUserData :copyfrom
insert into "user_data" ("id", "user")
values (sqlc.arg(id_parameter), sqlc.arg(user_parameter));
Configuration
{
"version": "2",
"sql": [
{
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql",
"gen": {
"go": {
"package": "models",
"sql_package": "pgx/v5",
"out": "models"
}
}
}
]
}
Playground URL
https://play.sqlc.dev/p/5e51915801b5b50a2d8836be41b4cc0503b5ce04e7c7a1e9efa6a12d719c7589
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
Version
1.22.0
What happened?
When using named parameters in your insert statement (
@param_nameorsqlc.arg(param_name)) the parameter name is used in the pgx CopyFrom method instead of the column name.In the playground example below, the copyfrom codegen is:
but it should be
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/5e51915801b5b50a2d8836be41b4cc0503b5ce04e7c7a1e9efa6a12d719c7589
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go