Skip to content

Fix Deprecation Warning About Passing AR Object Directly to quote

Jason Goodman requested to merge fix-ar-object-to-quote-deprecation-warning into master

What does this MR do and why?

The test suite produces ActiveRecord deprecation warnings like the following:

DEPRECATION WARNING: Passing an Active Record object to `quote` directly is deprecated
and will be no longer quoted as id value in Rails 6.2.
 (called from block in write_using_load_balancer at /Users/jason/code/gdk/gitlab/lib/gitlab/database/load_balancing/connection_proxy.rb:126)

This MR fixes the warnings by passing the object id directly to the Gitlab::ObjectHierarchy#base_and_ancestors_cte function rather than passing the entire object.

This change makes more sense stylistically, regardless of the ActiveRecord deprecation warnings, as the base_and_ancestors_cte function signature offers a clue that it expects an id rather than an entire object - it names the parameter stop_id.

How to set up and validate locally

  1. Run bin/rspec spec/models/group_spec.rb on master to see the deprecation warning messages.

  2. Run bin/rspec spec/models/group_spec.rb on this branch to see that the deprecation warnings are gone.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jason Goodman

Merge request reports