fix: include through associations referenced in filters in ResourcesGetter #742
+173
−0
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.
Hi 👋
Background
This PR is a follow up to my previous PR: #732
forest_liana 9.12.0 introduced a db query optimisation which includes specifying fields which are to be fetched from the database.
I've found another situation where this causes an issue. Specifically, when there is a filter or multiple filters applied on the forest admin frontend on a through association which is not a displayed column.
I hope the specs I included explain the exact situation. You can reproduce the error if you comment out line 351 of
app/services/forest_liana/resources_getter.rb
(select << "#{@resource.table_name}.#{association.foreign_key}"
) and run the new specs.I'd appreciate your opinions on the approach taken and would be happy to help validate any alternative ones.
--
We've also experienced a few similar issues related to polymorphic associations which this PR does not fix.
I've had a hard time investigating those. However, I've found out that uncommenting this particular line in
lib/forest_liana/active_record_override.rb
seems to fix most of them.Could you consider uncommenting this line in the next release? The issues I've mentioned block us from updating the gem at the moment.
Affected Versions
Forest agent (forest_liana) >= 9.12.0
Definition of Done
General
Security