Skip to content

query_parameter_limit broke the generated code #2263

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

Closed
bokunodev opened this issue May 5, 2023 · 1 comment · Fixed by #2578
Closed

query_parameter_limit broke the generated code #2263

bokunodev opened this issue May 5, 2023 · 1 comment · Fixed by #2578

Comments

@bokunodev
Copy link

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

@bokunodev bokunodev added bug Something isn't working triage New issues that hasn't been reviewed labels May 5, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang 💻 linux and removed triage New issues that hasn't been reviewed labels Jun 6, 2023
@tychy
Copy link
Contributor

tychy commented Aug 5, 2023

(note) A minimum case to regenerate this issue.
https://play.sqlc.dev/p/956cd1d3c1f7d528b2adaa59ed7e9a97daef623cc396bcbb0ffdcd5eb554e83c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants