Skip to content

Commit

Permalink
fix (engine/sqlite): normalize table names (sqlc-dev#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvns authored and kyleconroy committed Nov 25, 2024
1 parent 0b952b4 commit aeddc66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/engine/sqlite/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ type Delete_stmt interface {
func (c *cc) convertDelete_stmtContext(n Delete_stmt) ast.Node {
if qualifiedName, ok := n.Qualified_table_name().(*parser.Qualified_table_nameContext); ok {

tableName := qualifiedName.Table_name().GetText()
tableName := identifier(qualifiedName.Table_name().GetText())
relation := &ast.RangeVar{
Relname: &tableName,
}
Expand Down Expand Up @@ -854,7 +854,7 @@ func (c *cc) convertReturning_caluseContext(n parser.IReturning_clauseContext) *
}

func (c *cc) convertInsert_stmtContext(n *parser.Insert_stmtContext) ast.Node {
tableName := n.Table_name().GetText()
tableName := identifier(n.Table_name().GetText())
rel := &ast.RangeVar{
Relname: &tableName,
}
Expand Down Expand Up @@ -936,7 +936,7 @@ func (c *cc) convertTablesOrSubquery(n []parser.ITable_or_subqueryContext) []ast
}

if from.Table_name() != nil {
rel := from.Table_name().GetText()
rel := identifier(from.Table_name().GetText())
rv := &ast.RangeVar{
Relname: &rel,
Location: from.GetStart().GetStart(),
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/sqlite/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type tableNamer interface {

func parseTableName(c tableNamer) *ast.TableName {
name := ast.TableName{
Name: c.Table_name().GetText(),
Name: identifier(c.Table_name().GetText()),
}
if c.Schema_name() != nil {
name.Schema = c.Schema_name().GetText()
Expand Down

0 comments on commit aeddc66

Please # to comment.