Исправление названия внешних ключей
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Ymnuk 2023-11-02 13:53:45 +03:00
parent b3d90e7b15
commit ef3413431d
2 changed files with 8 additions and 1 deletions

View File

@ -65,14 +65,19 @@ func GetModelNameAngular(project *structs.Project, value structs.VisField) strin
}
func FieldInTableByName(name string, table *structs.Table) *structs.Field {
/*if table != nil && table.Name == "ratio_gender_age" {
fmt.Println(table)
}*/
for i := range table.Fields {
if table.Fields[i].Name == FieldNamePrepare(name) {
return &table.Fields[i]
}
}
for i := range table.FkFields {
//fmt.Println(FieldNamePrepare(name))
if table.FkFields[i].Name == FieldNamePrepare(name) ||
table.FkFields[i].Name+"ID" == FieldNamePrepare(name) {
table.FkFields[i].Name+"ID" == FieldNamePrepare(name) ||
table.FkFields[i].Name+"Id" == FieldNamePrepare(name) {
return &structs.Field{
Name: table.FkFields[i].Name,

View File

@ -107,6 +107,8 @@ func FieldNamePrepare(value string) string {
value = string(asRunes)
i = strings.Index(value, "_")
}
var regexpForReplace = regexp.MustCompile(`([Ii][Dd]$)`)
value = regexpForReplace.ReplaceAllString(value, "ID")
return value
}