Ban deprecation warning related to merging AR conditions
What does this MR do and why?
Ban deprecation warning related to merging AR conditions
Now, the following deprecation warning will fail in developmen/test/CI:
DEPRECATION WARNING: Merging (("project_features"."merge_requests_access_level" IN ($1, $2) OR "project_features"."merge_requests_access_level" IS NULL)) and (("project_features"."merge_requests_access_level" > 0 OR "project_features"."merge_requests_access_level" IS NULL)) no longer maintain both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use
relation.merge(other, rewhere: true)
. (called from block in class:Project at /srv/gitlab/app/models/project.rb:700)
How to set up and validate locally
In Rails console (development
) do:
[1] pry(main)> message = %{Merging (("project_features"."merge_requests_access_level" IN ($1, $2) OR "project_features"."merge_requests_access_level" IS NULL)) and (("project_features"."merge_requests_access_level" > 0 OR "project_features"."merge_requests_access_level" IS NULL)) no longer maintain both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`. (called from block in <class:Project> at /srv/gitlab/app/models/project.rb:700)}
=> "Merging ((\"project_features\".\"merge_requests_access_level\" IN ($1, $2) OR \"project_features\".\"merge_requests_access_level\" IS NULL)) and ((\"project_features\".\"merge_requests_access_level\" > 0 OR \"project_features\".\"merge_requests_access_level\" IS NULL)) no longer maintain both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`. (called from block in <class:Project> at /srv/gitlab/app/models/project.rb:700)"
[2] pry(main)> ActiveSupport::Deprecation.warn(message)
DEPRECATION WARNING: Merging (("project_features"."merge_requests_access_level" IN ($1, $2) OR "project_features"."merge_requests_access_level" IS NULL)) and (("project_features"."merge_requests_access_level" > 0 OR "project_features"."merge_requests_access_level" IS NULL)) no longer maintain both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`. (called from block in <class:Project> at /srv/gitlab/app/models/project.rb:700) (called from <main> at bin/rails:4)
Exception: DEPRECATION WARNING: Merging (("project_features"."merge_requests_access_level" IN ($1, $2) OR "project_features"."merge_requests_access_level" IS NULL)) and (("project_features"."merge_requests_access_level" > 0 OR "project_features"."merge_requests_access_level" IS NULL)) no longer maintain both conditions, and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`. (called from block in <class:Project> at /srv/gitlab/app/models/project.rb:700) (called from <main> at bin/rails:4)
from /home/peter/devel/gitlab/gdk/gitlab/config/initializers/00_deprecations.rb:26:in `block in <main>'
This prevents recurring issues like #414556 (closed) and #391393 (closed).
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.