Skip to content

Commit

Permalink
Use PG Connection#escape over Connection.escape
Browse files Browse the repository at this point in the history
Also fix AbstractMysqlAdapterTest
  • Loading branch information
byroot committed Feb 24, 2022
1 parent e28972a commit a2dc26e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Expand Up @@ -43,7 +43,7 @@ def quote(value) # :nodoc:

# Quotes strings for use in SQL input.
def quote_string(s) # :nodoc:
PG::Connection.escape(s)
@connection.escape(s)
end

# Checks the following cases:
Expand Down
26 changes: 14 additions & 12 deletions activerecord/test/cases/adapters/abstract_mysql_adapter_test.rb
Expand Up @@ -3,20 +3,22 @@
require "cases/helper"

class AbstractMysqlAdapterTest < ActiveRecord::Mysql2TestCase
class ExampleMysqlAdapter < ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter; end
if current_adapter?(:Mysql2Adapter)
class ExampleMysqlAdapter < ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter; end

def setup
@conn = ExampleMysqlAdapter.new(
ActiveRecord::ConnectionAdapters::Mysql2Adapter.new_client({}),
ActiveRecord::Base.logger,
nil,
{ socket: File::NULL }
)
end
def setup
@conn = ExampleMysqlAdapter.new(
ActiveRecord::ConnectionAdapters::Mysql2Adapter.new_client({}),
ActiveRecord::Base.logger,
nil,
{ socket: File::NULL }
)
end

def test_execute_not_raising_error
assert_nothing_raised do
@conn.execute("SELECT 1")
def test_execute_not_raising_error
assert_nothing_raised do
@conn.execute("SELECT 1")
end
end
end
end
Expand Up @@ -38,6 +38,10 @@ def exec_params(*)
{}
end

def escape(query)
PG::Connection.escape(query)
end

def reset
raise PG::ConnectionBad, "I'll be rescued by the reconnect method"
end
Expand Down

0 comments on commit a2dc26e

Please sign in to comment.