Skip to content

Unknown node type *ast.SetOprStmt #2260

Closed
@dansimau

Description

@dansimau

Version

1.17.2

What happened?

sqlc fails to generate on MySQL when there is a UNION inside a subquery that we're selecting from.

Relevant log output

sqlc generate failed.
2023/05/04 09:31:21 dolphin.convert: Unknown node type *ast.SetOprStmt
2023/05/04 09:31:21 dolphin.convert: Unknown node type *ast.SetOprStmt
# package db
query.sql:9:1: edited query syntax is invalid: syntax error near "FROM ("

Database schema

No response

SQL queries

-- name: TestSubqueryUnion :many
SELECT tmp.* FROM (
  SELECT * FROM authors
  UNION
  SELECT * FROM authors
) tmp LIMIT 5;

Configuration

No response

Playground URL

https://play.sqlc.dev/p/4963c8a8ba696143e0a564fa4c164c51c54d9460b5494c32ddc2c0269a20f866

What operating system are you using?

No response

What database engines are you using?

MySQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions