From 3c07d25cfc9f813c8aee149ea2a462e3e6bdf006 Mon Sep 17 00:00:00 2001 From: hirocaster Date: Thu, 27 Apr 2023 18:50:01 +0900 Subject: [PATCH 1/6] Start commits fix warnings on Ruby 2.7.x From dbdd1a9c473522f17a837649836422df7beff734 Mon Sep 17 00:00:00 2001 From: hirocaster Date: Thu, 27 Apr 2023 19:09:24 +0900 Subject: [PATCH 2/6] Output warnings for develop --- spec/spec_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 618f2f9d..b2e5d912 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,17 @@ require "rubygems" require "bundler/setup" +# https://www.ruby-lang.org/ja/news/2020/10/02/ruby-2-7-2-released/ +# Feature #17000: 2.7.2 turns off deprecation warnings by default +# https://bugs.ruby-lang.org/issues/17000 +ruby_version = Gem::Version.create(RUBY_VERSION) +ruby27_version = Gem::Version.create("2.7.2") +if ruby_version >= ruby27_version + if ENV["WARNING"] + Warning[:deprecated] = true + end +end + require "rails" require "action_view" require "action_dispatch" From 1a0b299ae93e59a10b77afffcca44541000612da Mon Sep 17 00:00:00 2001 From: hirocaster Date: Tue, 9 May 2023 22:17:39 +0900 Subject: [PATCH 3/6] Fix warning `Using the last argument as keyword parameters is deprecated` --- lib/active_record/turntable/cluster.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_record/turntable/cluster.rb b/lib/active_record/turntable/cluster.rb index 3e6f67a9..8e960a08 100644 --- a/lib/active_record/turntable/cluster.rb +++ b/lib/active_record/turntable/cluster.rb @@ -45,11 +45,11 @@ def shards_transaction(shards = [], options = {}, in_recursion = false, &block) end shard = to_shard(shards.shift) if shards.present? - shard.connection.transaction(options) do + shard.connection.transaction(**options) do shards_transaction(shards, options, true, &block) end else - shard.connection.transaction(options) do + shard.connection.transaction(**options) do yield end end From e71b241e2f9c322d269cbf99f4e05f0b9f08168b Mon Sep 17 00:00:00 2001 From: hirocaster Date: Tue, 9 May 2023 22:20:54 +0900 Subject: [PATCH 4/6] Fix warning `deprecated Object#=~ is called on Arel::InsertManager; it always returns nil` --- lib/active_record/turntable/connection_proxy/mixable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_record/turntable/connection_proxy/mixable.rb b/lib/active_record/turntable/connection_proxy/mixable.rb index 247c4cfb..a65b5f86 100644 --- a/lib/active_record/turntable/connection_proxy/mixable.rb +++ b/lib/active_record/turntable/connection_proxy/mixable.rb @@ -9,8 +9,8 @@ module Mixable def mixable?(method, *args) (method.to_s =~ METHODS_REGEXP && - args.first !~ EXCLUDE_QUERY_REGEXP) || - (method.to_s == "execute" && args.first =~ QUERY_REGEXP) + args.first.to_s !~ EXCLUDE_QUERY_REGEXP) || + (method.to_s == "execute" && args.first.to_s =~ QUERY_REGEXP) end end end From b435e51e243f137d214191923c6d0ee4f9f0f506 Mon Sep 17 00:00:00 2001 From: hirocaster Date: Thu, 27 Apr 2023 18:50:01 +0900 Subject: [PATCH 5/6] Start commits fix warnings on Ruby 2.7.x From c1ce2b4b1aadfc78c293cccdbae8bbedf13eb6b1 Mon Sep 17 00:00:00 2001 From: hirocaster Date: Thu, 8 Jun 2023 18:26:33 +0900 Subject: [PATCH 6/6] Fix deprecated Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call --- lib/active_record/turntable/connection_proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/active_record/turntable/connection_proxy.rb b/lib/active_record/turntable/connection_proxy.rb index 727e0f1e..03bb8507 100644 --- a/lib/active_record/turntable/connection_proxy.rb +++ b/lib/active_record/turntable/connection_proxy.rb @@ -33,7 +33,7 @@ def cluster def transaction(options = {}, &block) with_master { - connection.transaction(options, &block) + connection.transaction(**options, &block) } end