Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Do not generate associations for _id fields if no Table object or database table present #839

Closed
ajibarra opened this issue Jul 8, 2022 · 3 comments · Fixed by #842

Comments

@ajibarra
Copy link
Member

ajibarra commented Jul 8, 2022

Description

When baking a model, if you database table has a field with _id suffix it generates a belongsTo association. It is usually useful but sometimes it is not an actual association.

i.e A users table with an external_id to store the user id in another app/service.

Currently Bake would generate a belongsTo association with Externals as alias, even if ExternalsTable does not exist and externals table does not exist onto database.

I would propose to only generate the association if any of the above conditions is met.

I have a partial solution already but I would like to know your thoughts.

@othercorey
Copy link
Member

othercorey commented Jul 8, 2022

This seems like #834

@ajibarra
Copy link
Member Author

ajibarra commented Jul 11, 2022

This seems like #834

I have created this one after working on #834 . However I understood the problem in that one was about validation and not the association itself. Please let me know if I misunderstood.

Anyway I can prepare a PR this week to avoid creating associations to table that does not exist.

@othercorey
Copy link
Member

othercorey commented Jul 11, 2022

The invalid association is a side-effect of the bug overall. However, removing an invalid association was simple compared to re-adding missing validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants