Skip to content

Commit dd00cd2

Browse files
committed
Move quote_string from trilogy and mysql2 adapters to abstract mysql adapter
Implementations of the method are exactly the same for trilogy and mysql2 adapters so we will benefit from it being explicitly shared from the abstract mysql adapter
1 parent d68e439 commit dd00cd2

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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 0 additions & 11 deletions
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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@ def supports_lazy_transactions?
125125
true
126126
end
127127

128-
def quote_string(string)
129-
with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn|
130-
conn.escape(string)
131-
end
132-
end
133-
134128
def connected?
135129
!(@raw_connection.nil? || @raw_connection.closed?)
136130
end

0 commit comments

Comments
 (0)