Skip to content

Commit 7de5e75

Browse files
committed
fix: ensure uniqueness on different fk
1 parent 4fb1fc8 commit 7de5e75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/generator/model.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ func BuildRelationFields(table objects.Table, relations []state.Relation) (mappe
332332
}
333333

334334
if r.JoinRelation != nil {
335-
r.Table = fmt.Sprintf("%sThrough%s", inflection.Plural(r.Table), utils.SnakeCaseToPascalCase(inflection.Singular(r.Through)))
335+
throughSuffix := fmt.Sprintf("%s_%s_%s_%s", r.Through, r.SourcePrimaryKey, r.TargetPrimaryKey, r.JoinsSourceForeignKey)
336+
r.Table = fmt.Sprintf("%sThrough%s", inflection.Plural(r.Table), utils.SnakeCaseToPascalCase(inflection.Singular(throughSuffix)))
336337
}
337338

338339
r.Tag = BuildJoinTag(&r)

0 commit comments

Comments
 (0)