fix: include through associations referenced in filters in ResourcesGetter#742
Conversation
|
Hi 👋 Thanks a lot for your contribution! I tried reproducing the issue on my side with a basic setup like this: If I hide the solar_panel column in Forest and apply one or multiple filters on the collection, everything seems to work as expected; no error is raised. Is there any particular configuration in your project that might help us better understand the conditions to reproduce the bug? Or maybe I misunderstood the expected behavior in this case? Happy to dig further if you can share more insights! |
|
Hi @matthv 👋 In the situation you're describing, I think you'd need to hide You can try using my branch, commenting out this line and running the specs I've added. They reflect our use case quite well. I've been thinking about some of the other issues we've encountered as well which would not be fixed by this PR. Unfortunately, I just don't have the capacity to investigate them further. Like I said before, uncommenting this line in |
|
I spent some time on this today and noticed that the Could you let me know if this fixes the issue you’ve been encountering? I'm also going to test your branch and will get back to you shortly. Thanks again for all the detailed feedback! 🙏 |
|
Hi @matthv Sorry for the delay in responding. I've looked at your fix and it does indeed cover the case which I attempted to fix with my PR 🎉 |
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.rbseems 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