-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Add own SQL strategy #844
Comments
I am very happy to accept a PR for this feature 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
I want to implement my own SQL strategy to fight some performance issues regarding subqueries and distinct keywords in the left_join strategy. My approach is, to skip the distinct as along as the all joins are belongs_to or has_one. This way, the query will run in 1/30 of the time on my system.
However, adding a custom strategy requires some monkey patching, which is quiet ugly:
Expected behavior
It would be nice to add a custom strategy like this:
The setter could recognize if the argument is a class or a symbol and add it to the allowed strategies. It would also have to be compatible with Zeitwerks, so when the to_prepare hook from Rails is triggered during development, the constant is removed and added again like I do in my
.install
method.I'll be happy to try for a PR, but I would need some guidance on how this could be implemented.
Actual behavior
System configuration
Rails version:
7.0.8.1
Ruby version:
3.2.1
CanCanCan version
3.5.0
The text was updated successfully, but these errors were encountered: