Skip to content

Commit df79216

Browse files
author
Ahmad Berahman
committed
fix(normalized): table and column names should not be normalized
fix(normalized): table and column names should not be normalized
1 parent b78e322 commit df79216

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

internal/codegen/golang/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func argName(name string) string {
173173
out := ""
174174
for i, p := range strings.Split(name, "_") {
175175
if i == 0 {
176-
out += strings.ToLower(p)
176+
out += p
177177
} else if p == "id" {
178178
out += "ID"
179179
} else {

internal/engine/dolphin/convert.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dolphin
22

33
import (
44
"log"
5-
"strings"
65

76
pcast "github.com/pingcap/tidb/pkg/parser/ast"
87
"github.com/pingcap/tidb/pkg/parser/mysql"
@@ -25,12 +24,8 @@ func todo(n pcast.Node) *ast.TODO {
2524
return &ast.TODO{}
2625
}
2726

28-
func identifier(id string) string {
29-
return strings.ToLower(id)
30-
}
31-
3227
func NewIdentifier(t string) *ast.String {
33-
return &ast.String{Str: identifier(t)}
28+
return &ast.String{Str: t}
3429
}
3530

3631
func (c *cc) convertAlterTableStmt(n *pcast.AlterTableStmt) ast.Node {
@@ -122,7 +117,7 @@ func (c *cc) convertAlterTableStmt(n *pcast.AlterTableStmt) ast.Node {
122117
}
123118

124119
func (c *cc) convertAssignment(n *pcast.Assignment) *ast.ResTarget {
125-
name := identifier(n.Column.Name.String())
120+
name := n.Column.Name.String()
126121
return &ast.ResTarget{
127122
Name: &name,
128123
Val: c.convert(n.Expr),
@@ -250,7 +245,7 @@ func convertColumnDef(def *pcast.ColumnDef) *ast.ColumnDef {
250245
}
251246
}
252247
columnDef := ast.ColumnDef{
253-
Colname: def.Name.String(),
248+
Colname: def.Name.Name.O,
254249
TypeName: &ast.TypeName{Name: types.TypeToStr(def.Tp.GetType(), def.Tp.GetCharset())},
255250
IsNotNull: isNotNull(def),
256251
IsUnsigned: isUnsigned(def),
@@ -285,7 +280,7 @@ func (c *cc) convertColumnNameExpr(n *pcast.ColumnNameExpr) *ast.ColumnRef {
285280
func (c *cc) convertColumnNames(cols []*pcast.ColumnName) *ast.List {
286281
list := &ast.List{Items: []ast.Node{}}
287282
for i := range cols {
288-
name := identifier(cols[i].Name.String())
283+
name := cols[i].Name.String()
289284
list.Items = append(list.Items, &ast.ResTarget{
290285
Name: &name,
291286
})
@@ -350,7 +345,7 @@ func (c *cc) convertFieldList(n *pcast.FieldList) *ast.List {
350345

351346
func (c *cc) convertFuncCallExpr(n *pcast.FuncCallExpr) ast.Node {
352347
schema := n.Schema.String()
353-
name := strings.ToLower(n.FnName.String())
348+
name := n.FnName.String()
354349

355350
// TODO: Deprecate the usage of Funcname
356351
items := []ast.Node{}
@@ -454,7 +449,7 @@ func (c *cc) convertSelectField(n *pcast.SelectField) *ast.ResTarget {
454449
}
455450
var name *string
456451
if n.AsName.O != "" {
457-
asname := identifier(n.AsName.O)
452+
asname := n.AsName.O
458453
name = &asname
459454
}
460455
return &ast.ResTarget{
@@ -630,7 +625,7 @@ func (c *cc) convertAdminStmt(n *pcast.AdminStmt) ast.Node {
630625
}
631626

632627
func (c *cc) convertAggregateFuncExpr(n *pcast.AggregateFuncExpr) *ast.FuncCall {
633-
name := strings.ToLower(n.F)
628+
name := n.F
634629
fn := &ast.FuncCall{
635630
Func: &ast.FuncName{
636631
Name: name,
@@ -1289,8 +1284,8 @@ func (c *cc) convertSplitRegionStmt(n *pcast.SplitRegionStmt) ast.Node {
12891284
}
12901285

12911286
func (c *cc) convertTableName(n *pcast.TableName) *ast.RangeVar {
1292-
schema := identifier(n.Schema.String())
1293-
rel := identifier(n.Name.String())
1287+
schema := n.Schema.String()
1288+
rel := n.Name.String()
12941289
return &ast.RangeVar{
12951290
Schemaname: &schema,
12961291
Relname: &rel,

internal/engine/dolphin/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
func parseTableName(n *pcast.TableName) *ast.TableName {
1111
return &ast.TableName{
12-
Schema: identifier(n.Schema.String()),
13-
Name: identifier(n.Name.String()),
12+
Schema: n.Schema.String(),
13+
Name: n.Name.String(),
1414
}
1515
}
1616

0 commit comments

Comments
 (0)