Skip to content

Commit 9954650

Browse files
authored
Merge pull request rails#49817 from Shopify/unify-quote-string-for-mysql2-and-trilogy
Move `quote_string` from trilogy and mysql2 adapters to abstract mysql adapter
2 parents 6c63b9b + dd00cd2 commit 9954650

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

+11
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,17 @@ def check_version # :nodoc:
659659
end
660660
end
661661

662+
#--
663+
# QUOTING ==================================================
664+
#++
665+
666+
# Quotes strings for use in SQL input.
667+
def quote_string(string)
668+
with_raw_connection(allow_retry: true, materialize_transactions: false) do |connection|
669+
connection.escape(string)
670+
end
671+
end
672+
662673
class << self
663674
def extended_type_map(default_timezone: nil, emulate_booleans:) # :nodoc:
664675
super(default_timezone: default_timezone).tap do |m|

activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb

-11
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ def error_number(exception)
115115
exception.error_number if exception.respond_to?(:error_number)
116116
end
117117

118-
#--
119-
# QUOTING ==================================================
120-
#++
121-
122-
# Quotes strings for use in SQL input.
123-
def quote_string(string)
124-
with_raw_connection(allow_retry: true, materialize_transactions: false) do |connection|
125-
connection.escape(string)
126-
end
127-
end
128-
129118
#--
130119
# CONNECTION MANAGEMENT ====================================
131120
#++

activerecord/lib/active_record/connection_adapters/trilogy_adapter.rb

-6
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ def supports_lazy_transactions?
116116
true
117117
end
118118

119-
def quote_string(string)
120-
with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn|
121-
conn.escape(string)
122-
end
123-
end
124-
125119
def connected?
126120
!(@raw_connection.nil? || @raw_connection.closed?)
127121
end

0 commit comments

Comments
 (0)