fix: verify type when fetching associations fields #3231
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3166
Fixes #3158
In the previous attempt #3230, I aimed to target the exact field type when fetching association fields. However, that approach was abandoned as it led down a rabbit hole and was difficult to stabilize. In some cases, identifying the exact field type would require passing it through params, which is not ideal for maintainability and simplicity.
This PR simplifies things by following the 80/20 rule. Instead of trying to pinpoint the exact field type, Avo now just checks if the field is one of the supported associations when fetching fields. This fixes the reported issue and similar ones without overcomplicating things.
Checklist: