Skip to content

query_parameter_limit broke the generated code #2263

Closed
@bokunodev

Description

@bokunodev

Version

Other

What happened?

with query_parameter_limit set to 3 (or any value)

func (q *Queries) AddNewUser(ctx context.Context, db DBTX, iD string, password string) (Users, error) {
	row := db.QueryRow(ctx, addNewUser, iD, password)
	err := row.Scan(&i.ID, &i.Password)
	return i, err
}

notice declaration of var i Users is missing
it affects only AddNewUser since its the only one that has < 3 parameters.

Relevant log output

No response

Database schema

drop table if exists "clients";
create table "clients"(
    "id"           uuid  not null primary key,
    "secret"       text  not null,
    "redirect_uri" text  not null,
    "claims"       jsonb not null
);

drop table if exists "users";
create table "users"(
    "id"          text not null primary key,
    "password"    text not null
);

SQL queries

-- name: AddNewClient :one
insert into "clients"(
    "id",
    "secret",
    "redirect_uri",
    "claims"
)
values (
    sqlc.arg('id'),
    sqlc.arg('secret'),
    sqlc.arg('redirect_uri'),
    sqlc.arg('claims')
)
returning *;

-- name: BulkAddNewClients :copyfrom
insert into "clients"(
    "id",
    "secret",
    "redirect_uri",
    "claims"
)
values (
    sqlc.arg('id'),
    sqlc.arg('secret'),
    sqlc.arg('redirect_uri'),
    sqlc.arg('claims')
);

-- name: DeleteClient :exec
delete from "clients" where "id" = sqlc.arg('id');

-- name: AddNewUser :one
insert into "users"(
    "id",
    "password"
)
values (
    sqlc.arg('id'),
    sqlc.arg('password')
)
returning *;

-- name: BulkAddNewUsers :copyfrom
insert into "users"(
    "id",
    "password"
)
values (
    sqlc.arg('id'),
    sqlc.arg('password')
);

-- name: DeleteUser :exec
delete from "users" where "id" = sqlc.arg('id');

Configuration

version: "2"
overrides:
  go:
    rename:
      redirect_uri: "RedirectURI"
    overrides:
      - db_type: "uuid"
        go_type:
          import: "github.com/aofei/sandid"
          type: "SandID"
      - db_type: "json"
        go_type:
          import: "encoding/json"
          type: "RawMessage"
      - db_type: "jsonb"
        go_type:
          import: "encoding/json"
          type: "RawMessage"
sql:
  - engine: "postgresql"
    schema: "internal/db/authumn.schema.sql"
    queries: "internal/db/authumn.query.sql"
    gen:
      go:
        out: "internal/db"
        package: "db"
        sql_package: "pgx/v5"
        emit_exact_table_names: true
        emit_methods_with_db_argument: true
        query_parameter_limit: 3

Playground URL

https://play.sqlc.dev/p/af9607b336d8ea4dee9a966b052679b54d15efe1b3d2e6493ceef59259f2ad83

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions