-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
UniqBeforePluck should recommend Distinct on rails 5 #91
Comments
Merged
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Oct 7, 2019
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Oct 7, 2019
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 5, 2020
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 5, 2020
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 5, 2020
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 7, 2020
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 7, 2020
santib
added a commit
to santib/rubocop-rails
that referenced
this issue
Jun 7, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Rails 5,
uniq
was deprecated in favour ofdistinct
on ActiveRecord relations: https://edgeguides.rubyonrails.org/5_0_release_notes.html#active-record-deprecationsThis means the documentation here is wrong: https://github.com/rubocop-hq/rubocop-rails/blob/master/lib/rubocop/cop/rails/uniq_before_pluck.rb#L23
Specifically,
Model.uniq.pluck(:id)
will raise (NoMethodError (undefined method
uniq' for #Class:0x000000000b339d10)). Whereas
Model.distinct.pluck(:id)` will still work.My suggestions are:
distinct
even ifuniq
was used beforehand.distinct
no matter what method was matched.Happy to do a PR if everyone is okay with this.
The text was updated successfully, but these errors were encountered: