From b864a5457a59ddfca3dae0f6b11de7443633392b Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 10 Jan 2021 17:32:17 +0800 Subject: [PATCH] Allow foreign key following the default naming conventions, close #3928 --- schema/relationship.go | 1 + 1 file changed, 1 insertion(+) diff --git a/schema/relationship.go b/schema/relationship.go index 4580fa53..ae0e0b2b 100644 --- a/schema/relationship.go +++ b/schema/relationship.go @@ -418,6 +418,7 @@ func (schema *Schema) guessRelation(relation *Relationship, field *Field, gl gue 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, schema.namer.ColumnName(foreignSchema.Table, strings.TrimSuffix(lookUpName, primaryField.Name)+"ID")) } for _, name := range lookUpNames {