MCPcopy Create free account
hub / github.com/apache/devlake / checkField

Method checkField

backend/plugins/customize/service/service.go:91–111  ·  view source on GitHub ↗

checkField checks if the field exist in table

(table, field string)

Source from the content-addressed store, hash-verified

89
90// checkField checks if the field exist in table
91func (s *Service) checkField(table, field string) (bool, errors.Error) {
92 if table == "" {
93 return false, errors.Default.New("empty table name")
94 }
95 if !strings.HasPrefix(field, "x_") {
96 return false, errors.Default.New("column name should start with `x_`")
97 }
98 if !s.nameChecker.MatchString(field) {
99 return false, errors.Default.New("invalid column name")
100 }
101 fields, err := s.GetFields(table)
102 if err != nil {
103 return false, err
104 }
105 for _, fld := range fields {
106 if fld.ColumnName == field {
107 return true, nil
108 }
109 }
110 return false, nil
111}
112
113// CreateField creates a new column for the table cf.TbName and creates a new record in the table `_tool_customized_fields`
114func (s *Service) CreateField(cf *customizeModels.CustomizedField) errors.Error {

Callers 2

CreateFieldMethod · 0.95
DeleteFieldMethod · 0.95

Calls 2

GetFieldsMethod · 0.95
NewMethod · 0.65

Tested by

no test coverage detected