sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Incorrect code gen without

Open nexovec opened this issue 1 year ago • 0 comments

Version

1.26.0

What happened?

Sqlc generates bindings for the query below don't take in any parameters and I think that's incorrect.

Relevant log output

/go/bin/sqlc version
v1.26.0
go version
go version go1.22.2 linux/amd6

Database schema

-- PvtStarredPacks
CREATE TABLE IF NOT EXISTS pvt_starred_packs (
    id SERIAL PRIMARY KEY,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updated_at TIMESTAMP,
    deleted_at TIMESTAMP,
    user_id INT NOT NULL,
    pack_id INT NOT NULL,
    FOREIGN KEY (pack_id) REFERENCES packs (id)
);

SQL queries

-- name: StarPack :exec
DO $$
BEGIN
    IF NOT EXISTS (
        SELECT 1
        FROM pvt_starred_packs
        WHERE user_id = $1 AND pack_id = $2
    ) THEN
        RAISE EXCEPTION 'Pack already starred';
    INSERT INTO pvt_starred_packs (user_id, pack_id) VALUES ($1, $2);
    END IF;
END $$;

Configuration

version: "2"
sql:
- name: internal
  engine: postgresql
  schema:
    - ./migrations
  queries:
    - ./queries/
  database:
    uri: postgresql://postgres:postgres@postgres:5432/main?sslmode=disable
  strict_function_checks: true
  gen:
    go:
      package: models
      out: .
      sql_package: pgx/v5
      emit_json_tags: true
      emit_pointers_for_null_types: true
      emit_all_enum_values: true
      emit_enum_valid_method: true
      emit_exported_queries: false
      json_tags_case_style: snake
      query_parameter_limit: 3

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

nexovec avatar Apr 20 '24 19:04 nexovec