MCPcopy
hub / github.com/davyxu/tabtoy / PreCheck

Function PreCheck

v3/checker/entry.go:8–47  ·  view source on GitHub ↗
(dataList *model.DataTableList)

Source from the content-addressed store, hash-verified

6)
7
8func PreCheck(dataList *model.DataTableList) {
9
10 type ArrayFieldDefine struct {
11 FieldName string
12 ObjectName string
13 }
14
15 fieldCountByField := map[ArrayFieldDefine]int{}
16
17 // 合并前的数据表
18 for _, tab := range dataList.AllTables() {
19
20 // 遍历输入数据的每一列
21 for _, header := range tab.Headers {
22
23 // 输入的列头,为空表示改列被注释
24 if header.TypeInfo == nil {
25 continue
26 }
27
28 fieldKey := ArrayFieldDefine{
29 FieldName: header.TypeInfo.FieldName,
30 ObjectName: header.TypeInfo.Name,
31 }
32
33 if header.TypeInfo.IsArray() {
34 arrayFieldCount := tab.ArrayFieldCount(header)
35 if preFieldCount, ok := fieldCountByField[fieldKey]; ok {
36
37 if preFieldCount != arrayFieldCount {
38 report.ReportError("ArrayMultiColumnDefineNotMatch")
39 }
40 } else {
41 fieldCountByField[fieldKey] = arrayFieldCount
42 }
43 }
44
45 }
46 }
47}
48
49// merge后检查
50func PostCheck(globals *model.Globals) {

Callers 1

CompileFunction · 0.92

Calls 4

ReportErrorFunction · 0.92
AllTablesMethod · 0.80
ArrayFieldCountMethod · 0.80
IsArrayMethod · 0.45

Tested by

no test coverage detected