Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

name parameter not resolved in do statement #3439

Open
sudodeo opened this issue Jun 13, 2024 · 1 comment
Open

name parameter not resolved in do statement #3439

sudodeo opened this issue Jun 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@sudodeo
Copy link

sudodeo commented Jun 13, 2024

Version

1.26.0

What happened?

when i use a named parameter in a do stament, the generated query does not resolve to a positional parameter. looks like it works as expected when i use the postgresql engine

Relevant log output

const createStreamer = `-- name: CreateStreamer :one
INSERT INTO streamers
(platform_id, platform_name, user_id)
VALUES
(?1, ?2, ?3)
ON CONFLICT (user_id, platform_name)
DO UPDATE SET
  platform_id = @platform_id
RETURNING id, created_at, platform_id, platform_name, user_id,updated_at
`

Database schema

CREATE TABLE IF NOT EXISTS streamers (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  platform_id VARCHAR(255) NOT NULL,
  platform_name VARCHAR(255) NOT NULL,
  user_id VARCHAR(255) NOT NULL,
  UNIQUE (user_id, platform_name)
);

SQL queries

-- name: CreateStreamer :one
INSERT INTO streamers
(platform_id, platform_name, user_id)
VALUES
(@platform_id, @platform_name, @user_id)
ON CONFLICT (user_id, platform_name)
DO UPDATE SET
  platform_id = @platform_id
RETURNING *;

Configuration

version: "2"
sql:
  - engine: "sqlite"
    queries: "db/queries"
    schema: "db/schema.sql"
    gen:
      go:
        package: "db"
        out: "db"
        emit_json_tags: true

Playground URL

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

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

@sudodeo sudodeo added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 13, 2024
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Aug 5, 2024
@benrosenblum
Copy link

Same thing seems to happen with ORDER BY

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants