Skip to content

Commit

Permalink
Merge pull request #2885 from actiontech/fix_missing_return_rule_error
Browse files Browse the repository at this point in the history
Fix missing return rule error
  • Loading branch information
LordofAvernus authored Jan 20, 2025
2 parents b0c7a61 + 3845e75 commit fdba800
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions sqle/api/controller/v1/database_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type SQLAuditResult struct {
Message string `json:"message" example:"避免使用不必要的内置函数md5()"`
RuleName string `json:"rule_name"`
DbType string `json:"db_type"`
ExecutionFailed bool `json:"execution_failed" example:"false"`
ErrorInfo string `json:"error_info"`
I18nAuditResultInfo model.I18nAuditResultInfo `json:"i18n_audit_result_info"`
}

Expand Down
15 changes: 2 additions & 13 deletions sqle/api/controller/v2/sql_audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,8 @@ func DirectAudit(c echo.Context) error {
}

func convertTaskResultToAuditResV2(ctx context.Context, task *model.Task) *AuditResDataV2 {
lang := locale.Bundle.GetLangTagFromCtx(ctx)
results := make([]AuditSQLResV2, len(task.ExecuteSQLs))
for i, sql := range task.ExecuteSQLs {

ar := make([]*AuditResult, len(sql.AuditResults))
for j := range sql.AuditResults {
ar[j] = &AuditResult{
Level: sql.AuditResults[j].Level,
Message: sql.AuditResults[j].GetAuditMsgByLangTag(lang),
RuleName: sql.AuditResults[j].RuleName,
DbType: task.DBType,
I18nAuditResultInfo: sql.AuditResults[j].I18nAuditResultInfo,
}
}

results[i] = AuditSQLResV2{
Number: sql.Number,
ExecSQL: sql.Content,
Expand Down Expand Up @@ -243,6 +230,8 @@ func convertAuditResultToAuditResV2(ctx context.Context, auditResults model.Audi
ar[i] = AuditResult{
Level: auditResults[i].Level,
Message: auditResults[i].GetAuditMsgByLangTag(lang),
ErrorInfo: auditResults[i].GetAuditErrorMsgByLangTag(lang),
ExecutionFailed: auditResults[i].ExecutionFailed,
RuleName: auditResults[i].RuleName,
I18nAuditResultInfo: auditResults[i].I18nAuditResultInfo,
}
Expand Down
7 changes: 7 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17287,6 +17287,13 @@ var doc = `{
"db_type": {
"type": "string"
},
"error_info": {
"type": "string"
},
"execution_failed": {
"type": "boolean",
"example": false
},
"i18n_audit_result_info": {
"type": "object",
"$ref": "#/definitions/model.I18nAuditResultInfo"
Expand Down
7 changes: 7 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17271,6 +17271,13 @@
"db_type": {
"type": "string"
},
"error_info": {
"type": "string"
},
"execution_failed": {
"type": "boolean",
"example": false
},
"i18n_audit_result_info": {
"type": "object",
"$ref": "#/definitions/model.I18nAuditResultInfo"
Expand Down
5 changes: 5 additions & 0 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3993,6 +3993,11 @@ definitions:
properties:
db_type:
type: string
error_info:
type: string
execution_failed:
example: false
type: boolean
i18n_audit_result_info:
$ref: '#/definitions/model.I18nAuditResultInfo'
type: object
Expand Down

0 comments on commit fdba800

Please sign in to comment.