Skip to content

fix: raise error when reference is configured for non-belongs_to relationship #712

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
henryzhan013:main
Mar 10, 2026
Merged

fix: raise error when reference is configured for non-belongs_to relationship #712
zachdaniel merged 1 commit intoash-project:mainfrom
henryzhan013:main

Conversation

@henryzhan013
Copy link
Contributor

Closes #423

Summary

Previously, configuring a reference on a has_many or has_one relationship was silently ignored during migration generation. This was confusing because users expected either a migration to be generated or an error message.

Now an error is raised with a helpful message:

Found reference configuration for relationship timeslots, but it is a has_many relationship. References can only be configured for belongs_to relationships, because the foreign key is defined on the table with the belongs_to relationship. To configure the behavior of this foreign key, add the reference configuration to the resource with the corresponding belongs_to relationship.

Test plan

  • Added test case that verifies error is raised for has_many reference
  • Existing tests pass

…tionship

Previously, configuring a reference on a has_many or has_one relationship
was silently ignored. Now an error is raised with a helpful message
explaining that references can only be configured on belongs_to
relationships, since that's where the foreign key exists.
@zachdaniel zachdaniel merged commit dff4528 into ash-project:main Mar 10, 2026
58 of 67 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

@henryzhan013
Copy link
Contributor Author

🚀 Thank you for your contribution! 🚀

You're welcome!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using references wrong does not generate error

2 participants