mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-20 00:00:27 +08:00
refactor: 数据同步优化 & 标签树支持双击展开节点 & mysql支持with语句
This commit is contained in:
@@ -136,6 +136,8 @@ func (d *dbSqlExecAppImpl) Exec(ctx context.Context, execSqlReq *dto.DbSqlExecRe
|
||||
return allExecRes, nil
|
||||
}
|
||||
|
||||
// mysql parser with语句会分解析为两条,故需要特殊处理
|
||||
currentWithSql := ""
|
||||
for _, stmt := range stmts {
|
||||
var execRes *dto.DbSqlExecRes
|
||||
var err error
|
||||
@@ -143,7 +145,8 @@ func (d *dbSqlExecAppImpl) Exec(ctx context.Context, execSqlReq *dto.DbSqlExecRe
|
||||
sql := stmt.GetText()
|
||||
dbSqlExecRecord := createSqlExecRecord(ctx, execSqlReq, sql)
|
||||
dbSqlExecRecord.Type = entity.DbSqlExecTypeOther
|
||||
sqlExec := &sqlExecParam{DbConn: dbConn, Sql: sql, Procdef: flowProcdef, Stmt: stmt, SqlExecRecord: dbSqlExecRecord}
|
||||
sqlExec := &sqlExecParam{DbConn: dbConn, Sql: currentWithSql + sql, Procdef: flowProcdef, Stmt: stmt, SqlExecRecord: dbSqlExecRecord}
|
||||
currentWithSql = ""
|
||||
|
||||
switch stmt.(type) {
|
||||
case *sqlstmt.SimpleSelectStmt:
|
||||
@@ -152,6 +155,8 @@ func (d *dbSqlExecAppImpl) Exec(ctx context.Context, execSqlReq *dto.DbSqlExecRe
|
||||
execRes, err = d.doSelect(ctx, sqlExec)
|
||||
case *sqlstmt.OtherReadStmt:
|
||||
execRes, err = d.doOtherRead(ctx, sqlExec)
|
||||
case *sqlstmt.WithStmt:
|
||||
currentWithSql = sql
|
||||
case *sqlstmt.UpdateStmt:
|
||||
execRes, err = d.doUpdate(ctx, sqlExec)
|
||||
case *sqlstmt.DeleteStmt:
|
||||
@@ -174,9 +179,13 @@ func (d *dbSqlExecAppImpl) Exec(ctx context.Context, execSqlReq *dto.DbSqlExecRe
|
||||
execRes, err = d.doExec(ctx, dbConn, sql)
|
||||
}
|
||||
|
||||
if currentWithSql != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if execRes == nil {
|
||||
execRes = &dto.DbSqlExecRes{Sql: sql}
|
||||
execRes = &dto.DbSqlExecRes{Sql: sqlExec.Sql}
|
||||
}
|
||||
execRes.ErrorMsg = err.Error()
|
||||
} else {
|
||||
@@ -624,7 +633,7 @@ func isInsert(sql string) bool {
|
||||
|
||||
func isOtherQuery(sql string) bool {
|
||||
sqlPrefix := strings.ToLower(sql[:10])
|
||||
return strings.Contains(sqlPrefix, "explain") || strings.Contains(sqlPrefix, "show")
|
||||
return strings.Contains(sqlPrefix, "explain") || strings.Contains(sqlPrefix, "show") || strings.Contains(sqlPrefix, "with")
|
||||
}
|
||||
|
||||
func isDDL(sql string) bool {
|
||||
|
||||
Reference in New Issue
Block a user