-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
Refactor adapters #1348
Refactor adapters #1348
Conversation
a93e94d
to
1759232
Compare
@deivid-rodriguez could you please review this refactoring. It should go after #1345 I had intended to completely remove the |
@deivid-rodriguez can we get this into the 4.0.0 release also? |
I can try to review it, can you fix conflicts? |
@deivid-rodriguez sorry I didn't realise it had conflicts, will fix asap. |
cc6b2aa
to
942a948
Compare
It's ready for review now @deivid-rodriguez |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the refactoring looks good. We lose the flexibility of adding more adapters in the future, and people lose the flexibility to do it themselves too by implementing the necessary classes. But I guess we have enough with ActiveRecord?
lib/ransack.rb
Outdated
require 'ransack/adapters/active_record' | ||
require 'ransack/adapters/active_record/ransack/visitor' | ||
require 'ransack/adapters/active_record/ransack/nodes/condition' | ||
require 'ransack/adapters/active_record/ransack/context' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm following this refactoring correctly, only the first two requires above are needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check this and get back to you @deivid-rodriguez
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I guess we have enough with ActiveRecord?
@deivid-rodriguez I think we keep it to ActiveRecord only, we already removed MongoDB.
lib/polyamorous.rb
Outdated
@@ -1 +0,0 @@ | |||
require 'polyamorous/polyamorous' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was some compatibility code for people using the old polyamorous gem when it lived separately. We could remove it too, but seems unrelated to refactoring the adapters, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deivid-rodriguez I found this line to be unnecessary, but you are right: it is unrelated to the adapter refactoring. I will pull it into it's own PR.
lib/ransack/nodes/condition.rb
Outdated
i18n_alias :a => :attribute, :p => :predicate, | ||
:m => :combinator, :v => :value | ||
i18n_alias a: :attribute, p: :predicate, | ||
m: :combinator, v: :value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this style improvement too (or the others similar to this), but maybe we can enable it separately and enforce it through RuboCop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point @deivid-rodriguez, I'll pull this into it's own PR.
@deivid-rodriguez I will look at these comments over the weekend. I wonder if we should hold the 4.0.0 release so that this can come in? It is not a breaking change, but it is a large refactoring. I can go either way (either 4.0.0 or 4.1.0) WDYT ? 🤔 |
I think we can hold it until you can have a look. Breaking Thanks for this @scarroll32! |
942a948
to
4081b12
Compare
4081b12
to
880629d
Compare
880629d
to
d0241da
Compare
d0241da
to
70e8238
Compare
@deivid-rodriguez could you please take another look at this in light of #1371 and #1370 ? |
@deivid-rodriguez are you OK to merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scarroll32 Yeah, sure. I haven't suffered the pain from maintaining these adapters, but if this is painful and no other ORM framework is supported other than ActiveRecord anyways, then it makes sense to get rid of all this.
Closes #1346