-
Notifications
You must be signed in to change notification settings - Fork 82
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
Does not respect association ON clause (acts_as_paranoid) #570
Comments
Can you create either a test or a demo app which shows the issue? Also, I've tagged this with |
Yes I think it only affects See failing spec: https://github.com/mrbrdo/mobility/blob/mrbrdo/spec/mobility/plugins/active_record/query_spec.rb#L114 |
@shioyama can you comment on this failing spec? |
Thanks for raising the issue.
The The Table backend uses aliases to distinguish between joins in different locales, so instead of If there was a simple way to add a Sorry about that! I suspect at least there's a fix that would work in a non-generic way, but I don't see it right now. |
I'd like to close this since I don't see it as an issue with Mobility, but I'll leave it open in case we can come to some generic solution. |
Possibly the last question from my OP? You can see how I patched it for now in my use case (AR backend): https://github.com/mrbrdo/spree_mobility/blob/main/lib/spree_mobility/core_ext/mobility/backends/active_record/table/mobility_acts_as_paranoid_decorator.rb |
It could be an option for the table backend, used in Actually, it's already possible if you subclass |
That's exactly what I did: https://github.com/mrbrdo/spree_mobility/blob/main/lib/spree_mobility/core_ext/mobility/backends/active_record/table/mobility_acts_as_paranoid_decorator.rb But was hoping for a cleaner way :) |
Let's say the Translation model includes acts_as_paranoid.
Typical Rails
Base.all.joins(:translations)
will correctly haveINNER JOIN ... ON ... ."deleted_at" IS NULL
However, the scopes/queries generated by Mobility will not include this
ON
condition.I'm not sure how to go about fixing this... It seems the ActiveRecord interface to joins is mostly private and I didn't find a way to get a complete join (e.g. Arel join with all conditions) from ActiveRecord. I didn't find a way in ActiveRecord to perform a join with a table alias (for an association with taking into account the ON conditions).
Any suggestion? Is there at least a single place / setting in Mobility where it would be possible to add the additional conditions for the joins Mobility generates internally?
The text was updated successfully, but these errors were encountered: