Skip to content

mysql reuse model(with ... as ...) generated failed! #3216

Open
@Panlq

Description

@Panlq

Version

1.25.0

What happened?

A bug happened!

Relevant log output

sqlc generate failed.
# package 
query.sql:12:24: table alias "b" does not exist

Database schema

CREATE TABLE authors (
  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'name',
  `status` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'status'
);

SQL queries

-- name: TestReuseModel :many

WITH filtered_data AS (
    SELECT *
    FROM authors where id in (sqlc.slice("id"))
)

SELECT a.id
FROM filtered_data AS a
LEFT JOIN filtered_data AS b
    ON a.id = b.id AND b.name != ?
WHERE b.name IS NULL;

Configuration

No response

Playground URL

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

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions