You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I start working in a new project with Postgres and might found an issue with the foreign keys generated.
When this happens?
I only have seen this issue when the constraint name is the same in multiple tables. i.e.
Table
Orders
FK
fk_customer_id
Table
Addresses
FK
fk_customer_id
Current result:
This is generating foreign keys functions with wrong names i.e.
return CustomerByCustomerIDByCustomerID(....
Expected result:
return CustomerByCustomerID(...
My findings:
After read the code, I think the issue might be solved in the SQL Query that retrieve the foreign keys
Filename: models/foreignkey.xo.go
Function: PostgresTableForeignKeys
...`FROM information_schema.table_constraints tc `+`JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name `+`AND tc.table_schema = kcu.table_schema `+// here can be added the new condition to match the table name// `AND tc.table_name = kcu.table_name` +`JOIN ( `+...
If I can support in anything else please let me know. (issue description, testing, etc.)
Best Regards.
The text was updated successfully, but these errors were encountered:
@jcomx Julio, thank you for the detailed description and proposed solution.
I've prepared PR with your fixes: PR 401.
I hope @kenshaw will handle it soon.
Hi, I start working in a new project with Postgres and might found an issue with the foreign keys generated.
When this happens?
I only have seen this issue when the constraint name is the same in multiple tables. i.e.
Current result:
This is generating foreign keys functions with wrong names i.e.
Expected result:
My findings:
After read the code, I think the issue might be solved in the SQL Query that retrieve the foreign keys
Filename:
models/foreignkey.xo.go
Function:
PostgresTableForeignKeys
If I can support in anything else please let me know. (issue description, testing, etc.)
Best Regards.
The text was updated successfully, but these errors were encountered: