sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Capital letters in table alias causes generation to fail

Open mlucic opened this issue 11 months ago • 1 comments

Version

1.25.0

What happened?

Trying to generate a query where there is a table alias with capital letters causes the generation to fail with the error column "id" does not exist. Changing the alias to have only lowercase letters fixes the problem. Both are valid for MySQL, so sqlc should not be erroring when there are capital letters in the alias.

Relevant log output

$ sqlc generate
# package sqlc
query.sql:16:5: column "id" does not exist

Database schema

CREATE TABLE `blue` (
  `id` int NOT NULL AUTO_INCREMENT
  PRIMARY KEY (`id`)
);

SQL queries

SELECT
    `A`.`id`
FROM
    blue AS `A`;

Configuration

version: "2"
sql:
  - engine: "mysql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "sqlc"
        out: "sqlc"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

mlucic avatar Mar 11 '24 16:03 mlucic