-
Notifications
You must be signed in to change notification settings - Fork 533
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
Test for missing inverse relationships #1422
Comments
Hi! I just hit a "missing inverse relationship" error. v10.x does not require inverse relationships but I see v11.x does. Just one person's feedback, but I suggest this is overly invasive. For example, we have a very large code base and purposely avoid bi-directional relationships so we can more easily manage dependencies between code/modules (e.g. avoid dependency cycles). This works fine with Perhaps this is something that can be reconsidered? EDIT: I see you may consider a flag to allow the rule to be disabled - that would satisfy our use case I think |
@SingleShot Thanks for the feedback. I will revisit this v11 change with your concern in mind and try to provide some guidance soon. |
Hi. Just checking back here. We're wondering if you've given further thought to this topic. We're of course using v11 at our own risk but do find requiring bidirectional relationships to be very undesirable. The spec implies relationships are optional and there is no requirement to define two-way relationships so I think loosening this back up to the behavior in v10 would be more compliant. I can imagine some users of the library would always want bidirectional relationships and others (like us) wouldn't so maybe having a config setting of Anyway, just checking back. |
I'm running into this as well on 0.11. It seems that it only occurs when the API request is asking for an included association, especially for associations that use For example, a Part/Tag architecture. Where a In the
If I wanted to include all tags for a
However, this is where the issue occurs and it's because JR cant determine the inverse relationship, and in v11 it needs to. (I agree this should be a configurable opt-in feature). But it can be worked around fairly easy. I resolved the error by adding the following:
Essentially you need to tell ActiveRecord this relation is bi-directional (I think thats the correct term? LOL). Then you need to specify the |
This issue is a (choose one):
Checklist before submitting:
Description
A way to detect missing inverse relationships is needed. I would like to be able to add a test to a project to ensure no new missing relationship conditions have been added. Should also account for intentionally having a missing inverse relationship, probably with a flag on the primary relationship.
There are probably other relationship tests we could add, so we should consider how to best handle these in a consistent manner.
The text was updated successfully, but these errors were encountered: