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

No parameter gets generated for CASE ? WHEN... #2847

Closed
chowey opened this issue Oct 13, 2023 · 0 comments · Fixed by #2852
Closed

No parameter gets generated for CASE ? WHEN... #2847

chowey opened this issue Oct 13, 2023 · 0 comments · Fixed by #2852
Milestone

Comments

@chowey
Copy link

chowey commented Oct 13, 2023

Version

1.22.0

What happened?

I use a CASE statement of the form CASE ? WHEN true THEN '1' WHEN false THEN '0' ELSE NULL END.

The generated Go function has no parameters for the ?.

Relevant log output

No response

Database schema

CREATE TABLE testing (
  id    int PRIMARY KEY,
  value text
);

SQL queries

UPDATE testing
SET value = CASE ? WHEN true THEN 'Hello' WHEN false THEN 'Goodbye' ELSE value END;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "mysql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

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

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

@chowey chowey added bug Something isn't working triage New issues that hasn't been reviewed labels Oct 13, 2023
@kyleconroy kyleconroy added 📚 mysql 🔧 golang 💻 darwin and removed triage New issues that hasn't been reviewed labels Oct 13, 2023
@kyleconroy kyleconroy added this to the 1.23.0 milestone Oct 13, 2023
kyleconroy added a commit that referenced this issue Oct 13, 2023
MySQL and PostgreSQL now have the same behavior, generating a nullable string parameter. That behavior isn't right, as we'd expect the parameter to be a boolean. This can be fixed by using a type case or the new annotations in #2800.

Fixes #2847
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.

2 participants