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

Failed to parse CASE-ELSE clause with v1.18.0 #2237

Closed
nozaq opened this issue Apr 28, 2023 · 0 comments · Fixed by #2238
Closed

Failed to parse CASE-ELSE clause with v1.18.0 #2237

nozaq opened this issue Apr 28, 2023 · 0 comments · Fixed by #2238
Labels
bug Something isn't working regression

Comments

@nozaq
Copy link
Contributor

nozaq commented Apr 28, 2023

Version

Other

What happened?

sqlc fails to parse the query when CASE expression has ELSE clause and its value is a constant.

The example query is as below.

SELECT CASE 
  WHEN id = $1 THEN 'foo'
  ELSE 'bar'
END is_one
FROM foo

sqlc fails to parse this query with the error: parse table name: unexpected node type: *ast.Null.

Relevant log output

parse table name: unexpected node type: *ast.Null

Database schema

CREATE TABLE foo (id text not null);

SQL queries

SELECT CASE 
  WHEN id = $1 THEN 'foo'
  ELSE 'bar'
END is_one
FROM foo

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "go",
      "engine": "postgresql",
      "sql_package": "pgx/v5",
      "name": "querytest",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/968c7c9391b3aa32774930ab1d635c081c72d6f23bdf2db7ff9c94dfba0f178a

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@nozaq nozaq added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 28, 2023
@kyleconroy kyleconroy added regression and removed triage New issues that hasn't been reviewed labels Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants