sqlboiler: ForeignFN conflicts with ColumnName
I am seeing a conflict in all my foreign keys for these two function. I can see that if you have user_id as a foreign key, you would get UserId as field and User() as foreign function?
I found the following logic help:
if foreignFn == fkColumnName {
if strings.HasPrefix(foreignFn, foreignTableName) {
foreignFn = foreignTableName
} else {
foreignFn += foreignTableName
}
}
So if you have CreatedBy to the User table, it would generate foreignn fn CreatedByUser() and if you have UserIdentifier on the User table, foreign fn would be User()
I know there are aliases in the config file, but when every table have a User field called created_by, it seems to be troublesome to have set same alias across 100 tables. If aliases work from the destination table or there is a global list of aliases that would be great as well.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
@yuzuy happy to accept a PR that behaves as I spec’d out above.
@konrin Yes. In detail, refer https://github.com/volatiletech/sqlboiler/issues/576#issuecomment-526716185 and https://github.com/volatiletech/sqlboiler/pull/780