sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Casing issue with DROP TABLE statement ...

Open TorrinLynn opened this issue 6 months ago • 2 comments

Version

1.29.0

What happened?

If schema.sql contains a mixed case table name, you can only drop the table using lowercase name, otherwise, you get a relation "<table name>" does not exist. The following schema.sql illustrates the problem:

CREATE TABLE Authors (
  id   INTEGER PRIMARY KEY,
  name text    NOT NULL
);

DROP TABLE Authors; -- generates relation "Authors" does not exist error

Changing the drop statement to DROP TABLE authors fixes the reported error.

The bug first appeared in 1.28.0 and continues to exist in 1.29.0

Relevant log output

# package tutorial
schema.sql:1:1: relation "Authors" does not exist
schema.sql:1:1: relation "authors" already exists

Database schema

CREATE TABLE Authors (
  id   INTEGER PRIMARY KEY,
  name text    NOT NULL
);

DROP TABLE Authors;

CREATE TABLE Authors (
  id   INTEGER PRIMARY KEY,
  name text    NOT NULL,
  bio  text
);

SQL queries


Configuration

version: "2"
sql:
  - engine: "sqlite"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "tutorial"
        out: "tutorial"

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

TorrinLynn avatar Apr 19 '25 00:04 TorrinLynn