[MM-20761] Fix and improve integrity check tool (#13246)
* Fix query and add tests * Support NULL values and improve output
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
dc610d201d
Коммит
72f3bb10c7
@@ -31,10 +31,28 @@ func printRelationalIntegrityCheckResult(data store.RelationalIntegrityCheckData
|
||||
return
|
||||
}
|
||||
for _, record := range data.Records {
|
||||
if record.ChildId != "" {
|
||||
fmt.Println(fmt.Sprintf(" Child %s (%s.%s) is missing Parent %s (%s.%s)", record.ChildId, data.ChildName, data.ChildIdAttr, record.ParentId, data.ChildName, data.ParentIdAttr))
|
||||
var parentId string
|
||||
|
||||
if record.ParentId == nil {
|
||||
parentId = "NULL"
|
||||
} else if *record.ParentId == "" {
|
||||
parentId = "empty"
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf(" Child is missing Parent %s (%s.%s)", record.ParentId, data.ChildName, data.ParentIdAttr))
|
||||
parentId = *record.ParentId
|
||||
}
|
||||
|
||||
if record.ChildId != nil {
|
||||
if parentId == "NULL" || parentId == "empty" {
|
||||
fmt.Println(fmt.Sprintf(" Child %s (%s.%s) has %s ParentIdAttr (%s.%s)", *record.ChildId, data.ChildName, data.ChildIdAttr, parentId, data.ChildName, data.ParentIdAttr))
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf(" Child %s (%s.%s) is missing Parent %s (%s.%s)", *record.ChildId, data.ChildName, data.ChildIdAttr, parentId, data.ChildName, data.ParentIdAttr))
|
||||
}
|
||||
} else {
|
||||
if parentId == "NULL" || parentId == "empty" {
|
||||
fmt.Println(fmt.Sprintf(" Child has %s ParentIdAttr (%s.%s)", parentId, data.ChildName, data.ParentIdAttr))
|
||||
} else {
|
||||
fmt.Println(fmt.Sprintf(" Child is missing Parent %s (%s.%s)", parentId, data.ChildName, data.ParentIdAttr))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user