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

Method toDBModel

backend/plugins/customize/api/field.go:45–63  ·  view source on GitHub ↗
(table string)

Source from the content-addressed store, hash-verified

43}
44
45func (f *Field) toDBModel(table string) (*models.CustomizedField, errors.Error) {
46 if !strings.HasPrefix(f.ColumnName, "x_") {
47 return nil, errors.BadInput.New("the columnName should start with x_")
48 }
49 if f.DisplayName == "" {
50 return nil, errors.BadInput.New("the displayName is empty")
51 }
52 t, ok := dal.ToColumnType(f.DataType)
53 if !ok {
54 return nil, errors.BadInput.New(fmt.Sprintf("the columnType:%s is unsupported", f.DataType))
55 }
56 return &models.CustomizedField{
57 TbName: table,
58 ColumnName: f.ColumnName,
59 DisplayName: f.DisplayName,
60 DataType: t,
61 Description: f.Description,
62 }, nil
63}
64
65func fromCustomizedField(cf models.CustomizedField) fieldResponse {
66 return fieldResponse{

Callers 1

CreateFieldsMethod · 0.95

Calls 1

NewMethod · 0.65

Tested by

no test coverage detected