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
When we generate a model, its relationships of type HasOne and HasMany has the foreign_key and owner_key parameters interchanged.
You can reproduce this with the test repository - https://github.com/adwiv/crud-gen-test-1. In this repo, we have added a migration for phones table which has a user_id foreign key. Thus a user can have multiple phone numbers.
When generating the User model (api only), the relation is generated like this:
The issue can be traced to ModelGenerator#L134. We are looking at foreign keys of a different table, so the foreign_table is actually owner table and the foreign_key is owner_key and vice versa.
The text was updated successfully, but these errors were encountered:
When we generate a model, its relationships of type HasOne and HasMany has the foreign_key and owner_key parameters interchanged.
You can reproduce this with the test repository - https://github.com/adwiv/crud-gen-test-1. In this repo, we have added a migration for
phones
table which has auser_id
foreign key. Thus a user can have multiple phone numbers.When generating the User model (api only), the relation is generated like this:
However the correct order of arguments is
The issue can be traced to ModelGenerator#L134. We are looking at foreign keys of a different table, so the foreign_table is actually owner table and the foreign_key is owner_key and vice versa.
The text was updated successfully, but these errors were encountered: