From 4f8d7ab1663af956719aa9ec693fb7599c83b7ef Mon Sep 17 00:00:00 2001 From: linxiaotao Date: Mon, 9 Oct 2023 16:12:51 +0800 Subject: [PATCH] modified: correct spelling of word column @winfredLIN --- sqle/driver/mysql/rule/rule.go | 16 ++++++++-------- sqle/driver/mysql/util/visitor.go | 10 +++++----- sqle/driver/mysql/util/visitor_test.go | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sqle/driver/mysql/rule/rule.go b/sqle/driver/mysql/rule/rule.go index a5e483af1f..00b0539794 100644 --- a/sqle/driver/mysql/rule/rule.go +++ b/sqle/driver/mysql/rule/rule.go @@ -2687,13 +2687,13 @@ func getOnConditionLeftAndRightType(onCondition *ast.OnCondition, createTableStm leftType = node.Tp.Tp default: // 默认获取子树的所有列 对应等号一侧 一般连接键只会有一个 不支持多个列的组合 - lVisitor := util.ColumeNameVisitor{} + lVisitor := util.ColumnNameVisitor{} binaryOperation.L.Accept(&lVisitor) - if len(lVisitor.ColumeNameList) > 1 { + if len(lVisitor.ColumnNameList) > 1 { log.Logger().Warn("规则:建议JOIN字段类型保持一致,连接键不支持多个列的组合") } - if len(lVisitor.ColumeNameList) == 1 { - leftType = getColumnType(lVisitor.ColumeNameList[0], createTableStmtMap) + if len(lVisitor.ColumnNameList) == 1 { + leftType = getColumnType(lVisitor.ColumnNameList[0], createTableStmtMap) } } @@ -2701,13 +2701,13 @@ func getOnConditionLeftAndRightType(onCondition *ast.OnCondition, createTableStm case *ast.FuncCastExpr: rightType = node.Tp.Tp default: - rVisitor := util.ColumeNameVisitor{} + rVisitor := util.ColumnNameVisitor{} binaryOperation.R.Accept(&rVisitor) - if len(rVisitor.ColumeNameList) > 1 { + if len(rVisitor.ColumnNameList) > 1 { log.Logger().Warn("规则:建议JOIN字段类型保持一致,连接键不支持多个列的组合") } - if len(rVisitor.ColumeNameList) > 0 { - rightType = getColumnType(rVisitor.ColumeNameList[0], createTableStmtMap) + if len(rVisitor.ColumnNameList) > 0 { + rightType = getColumnType(rVisitor.ColumnNameList[0], createTableStmtMap) } } diff --git a/sqle/driver/mysql/util/visitor.go b/sqle/driver/mysql/util/visitor.go index 0df0bf8e02..e31bd403d5 100644 --- a/sqle/driver/mysql/util/visitor.go +++ b/sqle/driver/mysql/util/visitor.go @@ -228,18 +228,18 @@ func (v *SelectVisitor) Leave(in ast.Node) (out ast.Node, ok bool) { return in, true } -type ColumeNameVisitor struct { - ColumeNameList []*ast.ColumnNameExpr +type ColumnNameVisitor struct { + ColumnNameList []*ast.ColumnNameExpr } -func (v *ColumeNameVisitor) Enter(in ast.Node) (out ast.Node, skipChildren bool) { +func (v *ColumnNameVisitor) Enter(in ast.Node) (out ast.Node, skipChildren bool) { switch stmt := in.(type) { case *ast.ColumnNameExpr: - v.ColumeNameList = append(v.ColumeNameList, stmt) + v.ColumnNameList = append(v.ColumnNameList, stmt) } return in, false } -func (v *ColumeNameVisitor) Leave(in ast.Node) (out ast.Node, ok bool) { +func (v *ColumnNameVisitor) Leave(in ast.Node) (out ast.Node, ok bool) { return in, true } diff --git a/sqle/driver/mysql/util/visitor_test.go b/sqle/driver/mysql/util/visitor_test.go index b34266c8e9..20db6ad599 100644 --- a/sqle/driver/mysql/util/visitor_test.go +++ b/sqle/driver/mysql/util/visitor_test.go @@ -106,7 +106,7 @@ func TestSelectFieldExtractor(t *testing.T) { } } -func TestColumeNameVisitor(t *testing.T) { +func TestColumnNameVisitor(t *testing.T) { tests := []struct { input string columnCount uint @@ -130,10 +130,10 @@ func TestColumeNameVisitor(t *testing.T) { stmt, err := parser.New().ParseOneStmt(tt.input, "", "") assert.NoError(t, err) - visitor := &ColumeNameVisitor{} + visitor := &ColumnNameVisitor{} stmt.Accept(visitor) - assert.Equal(t, tt.columnCount, uint(len(visitor.ColumeNameList))) + assert.Equal(t, tt.columnCount, uint(len(visitor.ColumnNameList))) }) } }