-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Rails 6 deprecates where.not as NOR & Rails 6.1 as NAND #565
Comments
Did you mean to write |
An alternative way to enforce this would be to configure Rails to raise on deprecation warnings:
|
yes, sorry, fixed! |
@jsolas Do you already have started with implementing this cop or do you have time capacities in the near future for it? Otherwise I can take care about it. @andyw8 Would you be willing to merge such a cop? I've seen you commented in rubocop/rails-style-guide#296 (comment), that you consider a chained not as bad, too. So what do you expect from this cop? |
@denzelem A cop would surely be nice to have. A PR is welcome.
I'd say the cop should raise an offence for multiple attributes. And tolerate chained |
config.active_support.deprecation = :raise It's not always feasible I suppose, e.g. if there are other deprecation warnings. |
Rails 6.1 changed how where.not works with multiple hash arguments. This cop identifies places where where.not is used with multiple hash arguments. It doesn't suggest corrections because depending on the rails version, different behaviours may be correct. ```ruby # bad User.where.not(trashed: true, role: 'admin') # good User.where.not('trashed = ? OR role = ?', true, 'admin') ```
Rails 6.1 changed how where.not works with multiple hash arguments. This cop identifies places where where.not is used with multiple hash arguments. It doesn't suggest corrections because depending on the rails version, different behaviours may be correct. ```ruby # bad User.where.not(trashed: true, role: 'admin') # good User.where.not('trashed = ? OR role = ?', true, 'admin') ```
Rails 6.1 changed how where.not works with multiple hash arguments. This cop identifies places where where.not is used with multiple hash arguments. It doesn't suggest corrections because depending on the rails version, different behaviours may be correct. ```ruby # bad User.where.not(trashed: true, role: 'admin') # good User.where.not('trashed = ? OR role = ?', true, 'admin') ```
Rails 6.1 changed how where.not works with multiple hash arguments. This cop identifies places where where.not is used with multiple hash arguments. It doesn't suggest corrections because depending on the rails version, different behaviours may be correct. ```ruby # bad User.where.not(trashed: true, role: 'admin') # good User.where.not('trashed = ? OR role = ?', true, 'admin') ```
Rails 6.1 changed how `where.not` works with multiple hash arguments. This cop identifies places where `where.not` is used with multiple hash arguments. It doesn't suggest corrections because depending on the rails version, different behaviours may be correct. ```ruby # bad User.where.not(trashed: true, role: 'admin') # good User.where.not('trashed = ? OR role = ?', true, 'admin') ```
…le-arguments [Fix #565] Add cop Rails/WhereNotWithMultipleConditions
Currently if you use Rails 5.2 you can do for example: Post.where.not(source_type: "Feed", source_id: 100) and if we do the same in Rails 6.0.0.rc1 shows us the warning
NOT conditions will no longer behave as NOR in Rails 6.1.To continue using NOR conditions, NOT each conditions manually.
This will make the migration process to Rails 6 difficult and it will not be correct to continue using the conditions as rails 5.2 does.
Describe the solution you'd like
Create a cop prohibiting the use of where.not with two arguments. I would like to contribute by creating it
Additional context
This is the Rails pull request where it was made rails/rails#36029
More details of the change in this article https://www.bigbinary.com/blog/rails-6-deprecates-where-not-working-as-nor-and-will-change-to-nand-in-rails-6-1
The text was updated successfully, but these errors were encountered: