Skip to content

Commit

Permalink
fix: ensure uniqueness on different fk
Browse files Browse the repository at this point in the history
  • Loading branch information
toopay committed Sep 8, 2024
1 parent 4fb1fc8 commit 7de5e75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/generator/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ func BuildRelationFields(table objects.Table, relations []state.Relation) (mappe
}

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

r.Tag = BuildJoinTag(&r)
Expand Down

0 comments on commit 7de5e75

Please sign in to comment.