Skip to content

Fix SQLite Update query generation #4028

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
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/relation_uppercase/sqlite/go/db.go

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

10 changes: 10 additions & 0 deletions internal/endtoend/testdata/relation_uppercase/sqlite/go/models.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.

20 changes: 20 additions & 0 deletions internal/endtoend/testdata/relation_uppercase/sqlite/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- name: TestSelect :many
SELECT
ID, USERNAME
FROM
USERS;

-- name: TestInsert :exec
INSERT INTO USERS (
ID, USERNAME
) VALUES (
?, ?
);

-- name: TestUpdate :exec
UPDATE USERS
SET USERNAME = ?
WHERE ID = ?;

-- name: TestDelete :exec
DELETE FROM USERS WHERE ID = ?;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Example queries for sqlc
CREATE TABLE USERS
(
ID TEXT NOT NULL,
USERNAME TEXT NOT NULL
);
16 changes: 16 additions & 0 deletions internal/endtoend/testdata/relation_uppercase/sqlite/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2",
"sql": [
{
"engine": "sqlite",
"schema": "schema.sql",
"queries": "query.sql",
"gen": {
"go": {
"package": "db",
"out": "go"
}
}
}
]
}
2 changes: 1 addition & 1 deletion internal/engine/sqlite/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ func (c *cc) convertUpdate_stmtContext(n Update_stmt) ast.Node {
}

relations := &ast.List{}
tableName := n.Qualified_table_name().GetText()
tableName := identifier(n.Qualified_table_name().GetText())
rel := ast.RangeVar{
Relname: &tableName,
Location: n.GetStart().GetStart(),
Expand Down
Loading