sqlc
sqlc copied to clipboard
fix (engine/sqlite): normalize table names (#3162)
This aims to fix #3162, where in SQLite if schema.sql contained CREATE TABLE "users" and query.sql contained SELECT * from users, it would complain relation "users" does not exist, because the quotes don't match.
I think this was happening because the identifier function (which removes quotes from table names) wasn't consistently being called everywhere in the parser. I went through and replaced all instances of n.Table_name().GetText() with identifier(n.Table_name().GetText()) and that seems to have fixed the issue.
I've also added a test which previously failed and now passes. Here's what the output was previously:
$ cd internal/endtoend/testdata/quoted_tablename/sqlite/
$ sqlc generate
# package querytest
query.sql:1:1: relation "users" does not exist