checkField checks if the field exist in table
(table, field string)
| 89 | |
| 90 | // checkField checks if the field exist in table |
| 91 | func (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` |
| 114 | func (s *Service) CreateField(cf *customizeModels.CustomizedField) errors.Error { |
no test coverage detected