From 4bd4fcc85dbebef3e7004da3d97f5a936ba09b76 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 10 May 2024 10:02:05 +0200 Subject: [PATCH] Fix `.with_connection` to not set current scope Fix: https://github.com/rails/rails/issues/51775 This us us being bitten by https://github.com/rails/rails/pull/50396 once more. We should really make this delegation much stricter. --- activerecord/lib/active_record/relation/delegation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index 8b0b008b49a95..c696c7eed7497 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -100,7 +100,7 @@ def #{method}(...) :to_sentence, :to_fs, :to_formatted_s, :as_json, :shuffle, :split, :slice, :index, :rindex, to: :records - delegate :primary_key, :connection, :transaction, to: :klass + delegate :primary_key, :lease_connection, :connection, :with_connection, :transaction, to: :klass module ClassSpecificRelation # :nodoc: extend ActiveSupport::Concern