Skip to content

Commit

Permalink
not need to use restore func
Browse files Browse the repository at this point in the history
  • Loading branch information
hasa1K committed May 31, 2024
1 parent e6ea655 commit 98d8f32
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions sqle/driver/mysql/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/actiontech/sqle/sqle/errors"

"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/format"
_model "github.com/pingcap/parser/model"
parserMysql "github.com/pingcap/parser/mysql"
)
Expand Down Expand Up @@ -627,7 +626,7 @@ func (i *MysqlDriverImpl) generateUpdateRollbackSql(stmt *ast.UpdateStmt) (strin
colChanged = true
if isPk {
isPkChanged = true
pkValue = restore(l.Expr)
pkValue = util.ExprFormat(l.Expr)
}
}
}
Expand Down Expand Up @@ -661,18 +660,6 @@ func (i *MysqlDriverImpl) generateUpdateRollbackSql(stmt *ast.UpdateStmt) (strin
return rollbackSql, "", nil
}

// 还原抽象语法树节点至SQL
func restore(node ast.Node) (sql string) {
var buf strings.Builder
rc := format.NewRestoreCtx(format.DefaultRestoreFlags, &buf)

if err := node.Restore(rc); err != nil {
return
}
sql = buf.String()
return
}

// getRecords select all data which will be update or delete.
func (i *MysqlDriverImpl) getRecords(tableName *ast.TableName, tableAlias string, where ast.ExprNode,
order *ast.OrderByClause, limit int64) ([]map[string]sql.NullString, error) {
Expand Down

0 comments on commit 98d8f32

Please sign in to comment.