MCPcopy Index your code
hub / github.com/apache/devlake / NewTableInfos

Function NewTableInfos

backend/server/api/plugininfo/plugininifo.go:84–119  ·  view source on GitHub ↗
(table dal.Tabler)

Source from the content-addressed store, hash-verified

82type PluginMetas []PluginMeta
83
84func NewTableInfos(table dal.Tabler) *TableInfos {
85 tableInfos := &TableInfos{
86 TableName: table.TableName(),
87 Error: nil,
88 }
89
90 fieldInfos := utils.WalkFields(reflect.TypeOf(table), nil)
91 schema, err := schema.Parse(table, &sync.Map{}, schema.NamingStrategy{})
92 if err != nil {
93 errstr := err.Error()
94 tableInfos.Error = &errstr
95 }
96
97 tableInfos.Field = make([]*TableInfo, 0, len(fieldInfos))
98 for _, field := range fieldInfos {
99 dbName := ""
100 dataType := ""
101 gormDataType := ""
102 if schema != nil {
103 if dbfield, ok := schema.FieldsByName[field.Name]; ok {
104 dbName = dbfield.DBName
105 dataType = string(dbfield.DataType)
106 gormDataType = string(dbfield.GORMDataType)
107 }
108 }
109 tableInfos.Field = append(tableInfos.Field, &TableInfo{
110 Name: field.Name,
111 Tags: string(field.Tag),
112 DbName: dbName,
113 DataType: dataType,
114 GORMDataType: gormDataType,
115 })
116 }
117
118 return tableInfos
119}
120
121type PluginInfo struct {
122 Name string `json:"name"`

Callers 1

GetFunction · 0.85

Calls 2

TableNameMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected