Skip to content

Commit 98d8f32

Browse files
committed
not need to use restore func
1 parent e6ea655 commit 98d8f32

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

sqle/driver/mysql/rollback.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/actiontech/sqle/sqle/errors"
1212

1313
"github.com/pingcap/parser/ast"
14-
"github.com/pingcap/parser/format"
1514
_model "github.com/pingcap/parser/model"
1615
parserMysql "github.com/pingcap/parser/mysql"
1716
)
@@ -627,7 +626,7 @@ func (i *MysqlDriverImpl) generateUpdateRollbackSql(stmt *ast.UpdateStmt) (strin
627626
colChanged = true
628627
if isPk {
629628
isPkChanged = true
630-
pkValue = restore(l.Expr)
629+
pkValue = util.ExprFormat(l.Expr)
631630
}
632631
}
633632
}
@@ -661,18 +660,6 @@ func (i *MysqlDriverImpl) generateUpdateRollbackSql(stmt *ast.UpdateStmt) (strin
661660
return rollbackSql, "", nil
662661
}
663662

664-
// 还原抽象语法树节点至SQL
665-
func restore(node ast.Node) (sql string) {
666-
var buf strings.Builder
667-
rc := format.NewRestoreCtx(format.DefaultRestoreFlags, &buf)
668-
669-
if err := node.Restore(rc); err != nil {
670-
return
671-
}
672-
sql = buf.String()
673-
return
674-
}
675-
676663
// getRecords select all data which will be update or delete.
677664
func (i *MysqlDriverImpl) getRecords(tableName *ast.TableName, tableAlias string, where ast.ExprNode,
678665
order *ast.OrderByClause, limit int64) ([]map[string]sql.NullString, error) {

0 commit comments

Comments
 (0)