Skip to content

bugfix: Normalize identifier usage for table names #4045

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- name: InsertUser :exec
INSERT INTO Users (full_name, "EmailAddress", created_at)
VALUES (?, ?, ?);

-- name: SelectUsers :many
SELECT id, full_name, "EmailAddress", created_at
FROM Users;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Test ALTER TABLE operations with mixed case table and column names
-- Verifies consistent handling of case sensitivity in DDL operations
CREATE TABLE Users (id integer primary key, name text, "Email" text);

-- Test renaming columns with different case formats
ALTER TABLE Users RENAME COLUMN name TO full_name;
ALTER TABLE Users RENAME COLUMN "Email" TO "EmailAddress";

-- Test adding a simple column
ALTER TABLE Users ADD COLUMN created_at text;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "sqlite",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}
8 changes: 7 additions & 1 deletion internal/endtoend/testdata/ddl_drop_table/sqlite/schema.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
CREATE TABLE venues (hi text);
DROP TABLE venues;
DROP TABLE venues;

CREATE TABLE Authors (id integer);
DROP TABLE Authors;

CREATE TABLE "Books" (id integer);
DROP TABLE "Books";
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/quoted_names_complex/sqlite/go/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- name: Placeholder :exec
SELECT 1;
22 changes: 22 additions & 0 deletions internal/endtoend/testdata/quoted_names_complex/sqlite/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Test complex quoted table and column names with special characters
-- Covers spaces, hyphens, uppercase, and mixed operations
CREATE TABLE "user profiles" (id integer primary key, data text);
CREATE TABLE "ORDERS" (id integer primary key, data text);
CREATE TABLE products (id integer primary key, data text);
CREATE TABLE "item-categories" (id integer primary key, data text);

-- Test ALTER statements with complex identifiers
ALTER TABLE "user profiles" RENAME COLUMN data TO "profile data";
ALTER TABLE "ORDERS" RENAME TO "customer_orders";
ALTER TABLE products ADD COLUMN "Price Info" text;

-- Test mixed case operations across different statement types
INSERT INTO "user profiles" ("profile data") VALUES ('test data');
UPDATE "ORDERS" SET data = 'updated' WHERE id = 1;
DELETE FROM products WHERE id = 1;

-- Test DROP with various identifier formats
DROP TABLE "user profiles";
DROP TABLE "customer_orders";
DROP TABLE "item-categories";
DROP TABLE products;
12 changes: 12 additions & 0 deletions internal/endtoend/testdata/quoted_names_complex/sqlite/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "sqlite",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading