Skip to content

Commit

Permalink
fix(engine/sqlite): Lowercase ast.ResTarget.Name (#2433)
Browse files Browse the repository at this point in the history
* fix(engine/sqlite): To lowercase ast.ResTarget.Name

The SQLite engine lowercases ast.ResTarget.Name to match the behavior of pg_query.

fix #2120

* test: add endtoend

* chore: v1.19.1
  • Loading branch information
orisano committed Jul 26, 2023
1 parent e7ab328 commit 7ff8e6f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 3 deletions.
31 changes: 31 additions & 0 deletions internal/endtoend/testdata/case_sensitive/sqlite/go/db.go

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

14 changes: 14 additions & 0 deletions internal/endtoend/testdata/case_sensitive/sqlite/go/models.go

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

29 changes: 29 additions & 0 deletions internal/endtoend/testdata/case_sensitive/sqlite/go/query.sql.go

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

12 changes: 12 additions & 0 deletions internal/endtoend/testdata/case_sensitive/sqlite/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE contacts (
pid TEXT,
CustomerName TEXT
);

-- name: InsertContact :exec
INSERT INTO contacts (
pid,
CustomerName
)
VALUES (?,?)
;
1 change: 1 addition & 0 deletions internal/endtoend/testdata/case_sensitive/sqlite/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version": "1", "packages": [{"path": "go", "engine": "sqlite", "schema": "query.sql", "queries": "query.sql", "name": "querytest"}]}
6 changes: 3 additions & 3 deletions internal/engine/sqlite/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (c *cc) getCols(core *parser.Select_coreContext) []ast.Node {
}

if col.AS_() != nil {
name := col.Column_alias().GetText()
name := identifier(col.Column_alias().GetText())
target.Name = &name
}

Expand Down Expand Up @@ -805,7 +805,7 @@ func (c *cc) convertExprLists(lists []parser.IExprContext) *ast.List {
func (c *cc) convertColumnNames(cols []parser.IColumn_nameContext) *ast.List {
list := &ast.List{Items: []ast.Node{}}
for _, c := range cols {
name := c.GetText()
name := identifier(c.GetText())
list.Items = append(list.Items, &ast.ResTarget{
Name: &name,
})
Expand Down Expand Up @@ -912,7 +912,7 @@ func (c *cc) convertUpdate_stmtContext(n Update_stmt) ast.Node {

list := &ast.List{}
for i, col := range n.AllColumn_name() {
colName := col.GetText()
colName := identifier(col.GetText())
target := &ast.ResTarget{
Name: &colName,
Val: c.convert(n.Expr(i)),
Expand Down

0 comments on commit 7ff8e6f

Please sign in to comment.