Skip to content

Commit 8e504d2

Browse files
author
xff
committed
修复语法审核dml语句AffectedRows不正确的bug
1 parent ae8bdf9 commit 8e504d2

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

goinsight/internal/apps/inspect/checker/stmt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func (s *Stmt) commonCheck(stmt ast.StmtNode, kv *kv.KVCache, fingerId string, s
2828
rule.RuleHint = ruleHint
2929
rule.CheckFunc(&rule, &stmt)
3030

31+
// 当为DML语句时,赋值AffectedRows
32+
if sqlType == "DML" {
33+
data.AffectedRows = rule.RuleHint.AffectedRows
34+
}
35+
3136
if len(rule.RuleHint.Summary) > 0 {
3237
data.Level = "WARN"
3338
data.Summary = append(data.Summary, rule.RuleHint.Summary...)

goinsight/internal/apps/inspect/controllers/hint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
)
1313

1414
type RuleHint struct {
15-
Summary []string `json:"summary"` // 摘要
16-
AffectedRows int `json:"affected_rows"`
15+
Summary []string `json:"summary"` // 摘要
16+
AffectedRows int `json:"affected_rows"` // 默认为0
1717
IsSkipNextStep bool // 是否跳过接下来的检查步骤
1818
DB *dao.DB
1919
KV *kv.KVCache

0 commit comments

Comments
 (0)