Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (engine/sqlite): normalize table names (#3162) #3657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jvns
Copy link

@jvns jvns commented Oct 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

warn when using quotes or parse the SQL
1 participant