Skip to content
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

Incorrect code gen without #3348

Open
nexovec opened this issue Apr 20, 2024 · 0 comments
Open

Incorrect code gen without #3348

nexovec opened this issue Apr 20, 2024 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@nexovec
Copy link

nexovec commented Apr 20, 2024

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 nexovec added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant