sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Unquote backticks in sqlite identifiers

Open JoeriAben opened this issue 2 months ago • 1 comments

Fixes #3350 Fixes #3684 Fixes #3800

In sqlite there is a quirky behavior where backticks are included in table and column names. This causes errors like relation "x" does not exist, even when the column or table is actually present.

The changes in this PR ensure that identifiers no longer include backticks as part of their names.

Steps to reproduce the issues this solves

schema.sql

CREATE TABLE `foo` (`bar` text);

queries.sql

-- name: GetFoo :many
SELECT bar FROM foo;

sqlc.yaml

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

output

> sqlc generate    
# package db
queries.sql:1:1: relation "foo" does not exist

JoeriAben avatar Oct 01 '25 22:10 JoeriAben

@kyleconroy please merge this PR, it's simple but solved a big problem for sqlite users.

fy0 avatar Nov 07 '25 08:11 fy0