From 0242f3194c15d10ad5037d4581e78cb70b13b648 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 27 May 2022 18:26:45 -0700 Subject: [PATCH] Avoid spurious keyword argument warning on Ruby 2.7 There is no reason to use **kwargs in either of these methods, as connect_start doesn't handle keywords (keywords passed to it will be treated as a positional hash). Fixes deprecation warning when using Sequel's postgres adapter in Ruby 2.7. --- lib/pg.rb | 4 ++-- lib/pg/connection.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pg.rb b/lib/pg.rb index 0e6a00c4b..a8375b98d 100644 --- a/lib/pg.rb +++ b/lib/pg.rb @@ -65,8 +65,8 @@ def self.version_string( include_buildnum=nil ) ### Convenience alias for PG::Connection.new. - def self.connect( *args, **kwargs, &block ) - Connection.new( *args, **kwargs, &block ) + def self.connect( *args, &block ) + Connection.new( *args, &block ) end diff --git a/lib/pg/connection.rb b/lib/pg/connection.rb index 0ac2a2162..5b03fa117 100644 --- a/lib/pg/connection.rb +++ b/lib/pg/connection.rb @@ -701,8 +701,8 @@ class << self # connection will have its +client_encoding+ set accordingly. # # Raises a PG::Error if the connection fails. - def new(*args, **kwargs) - conn = self.connect_start(*args, **kwargs ) or + def new(*args) + conn = self.connect_start(*args) or raise(PG::Error, "Unable to create a new connection") raise(PG::ConnectionBad, conn.error_message) if conn.status == PG::CONNECTION_BAD