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

sqlc completely skips over arguments in complex queries with no error messages #3665

Open
maddsua opened this issue Oct 21, 2024 · 0 comments

Comments

@maddsua
Copy link

maddsua commented Oct 21, 2024

Version

1.27.0

What happened?

The generated output lacks any query parameters which yields it completely useless. All the sqlc.arg() are ignored with no errors raised.
When switched annotation to batchexec the following error is encountered: :batch* commands require parameters

Relevant log output

No response

Database schema

CREATE TABLE usage (
  id   BIGSERIAL PRIMARY KEY,
  created_at timestampz not null,
  user_id bigint not null,
  delta  bigint
);

SQL queries

-- name: UpdateUsage :exec
merge into usage using (
	select usage.id
	from (select 1) as dummy
		left join usage
		on user_id = sqlc.arg(user_id)
			and created_at >= now() - interval '1 hour'
	order by id desc
	limit 1
) ref on usage.id = ref.id
when matched then
	update
	set delta = delta + sqlc.arg(delta)
when not matched then
	insert (user_id, delta)
	values (sqlc.arg(user_id), sqlc.arg(delta));

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "postgresql",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

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

What operating system are you using?

Windows

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@maddsua maddsua added the bug Something isn't working label Oct 21, 2024
@maddsua maddsua changed the title sqlc completely skips over arguments in complexqueries with no error messages sqlc completely skips over arguments in complex queries with no error messages Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@maddsua and others