Allow foreign key following the default naming conventions, close #3928

This commit is contained in:
Jinzhu 2021-01-10 17:32:17 +08:00
parent fe553a7c1a
commit b864a5457a
1 changed files with 1 additions and 0 deletions

View File

@ -418,6 +418,7 @@ func (schema *Schema) guessRelation(relation *Relationship, field *Field, gl gue
if len(primaryFields) == 1 { if len(primaryFields) == 1 {
lookUpNames = append(lookUpNames, strings.TrimSuffix(lookUpName, primaryField.Name)+"ID") lookUpNames = append(lookUpNames, strings.TrimSuffix(lookUpName, primaryField.Name)+"ID")
lookUpNames = append(lookUpNames, strings.TrimSuffix(lookUpName, primaryField.Name)+"Id") lookUpNames = append(lookUpNames, strings.TrimSuffix(lookUpName, primaryField.Name)+"Id")
lookUpNames = append(lookUpNames, schema.namer.ColumnName(foreignSchema.Table, strings.TrimSuffix(lookUpName, primaryField.Name)+"ID"))
} }
for _, name := range lookUpNames { for _, name := range lookUpNames {