Skip to content

Commit 93b5fc1

Browse files
Rename MySQL::DatabaseStatements => Mysql2::DatabaseStatements
1 parent 8bdf5e3 commit 93b5fc1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb renamed to activerecord/lib/active_record/connection_adapters/mysql2/database_statements.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module ActiveRecord
44
module ConnectionAdapters
5-
module MySQL
5+
module Mysql2
66
module DatabaseStatements
77
# Returns an ActiveRecord::Result instance.
88
def select_all(*, **) # :nodoc:
@@ -120,7 +120,7 @@ def multi_statements_enabled?
120120
if flags.is_a?(Array)
121121
flags.include?("MULTI_STATEMENTS")
122122
else
123-
flags.anybits?(Mysql2::Client::MULTI_STATEMENTS)
123+
flags.anybits?(::Mysql2::Client::MULTI_STATEMENTS)
124124
end
125125
end
126126

@@ -130,11 +130,11 @@ def with_multi_statements
130130
end
131131

132132
with_raw_connection do |conn|
133-
conn.set_server_option(Mysql2::Client::OPTION_MULTI_STATEMENTS_ON)
133+
conn.set_server_option(::Mysql2::Client::OPTION_MULTI_STATEMENTS_ON)
134134

135135
yield
136136
ensure
137-
conn.set_server_option(Mysql2::Client::OPTION_MULTI_STATEMENTS_OFF)
137+
conn.set_server_option(::Mysql2::Client::OPTION_MULTI_STATEMENTS_OFF)
138138
end
139139
end
140140

activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require "active_record/connection_adapters/abstract_mysql_adapter"
4-
require "active_record/connection_adapters/mysql/database_statements"
4+
require "active_record/connection_adapters/mysql2/database_statements"
55

66
gem "mysql2", "~> 0.5"
77
require "mysql2"
@@ -28,12 +28,12 @@ class Mysql2Adapter < AbstractMysqlAdapter
2828

2929
ADAPTER_NAME = "Mysql2"
3030

31-
include MySQL::DatabaseStatements
31+
include Mysql2::DatabaseStatements
3232

3333
class << self
3434
def new_client(config)
35-
Mysql2::Client.new(config)
36-
rescue Mysql2::Error => error
35+
::Mysql2::Client.new(config)
36+
rescue ::Mysql2::Error => error
3737
if error.error_number == ConnectionAdapters::Mysql2Adapter::ER_BAD_DB_ERROR
3838
raise ActiveRecord::NoDatabaseError.db_error(config[:database])
3939
elsif error.error_number == ConnectionAdapters::Mysql2Adapter::ER_ACCESS_DENIED_ERROR
@@ -54,7 +54,7 @@ def initialize(...)
5454
if @config[:flags].kind_of? Array
5555
@config[:flags].push "FOUND_ROWS"
5656
else
57-
@config[:flags] |= Mysql2::Client::FOUND_ROWS
57+
@config[:flags] |= ::Mysql2::Client::FOUND_ROWS
5858
end
5959

6060
@connection_parameters ||= @config
@@ -159,9 +159,9 @@ def get_full_version
159159
end
160160

161161
def translate_exception(exception, message:, sql:, binds:)
162-
if exception.is_a?(Mysql2::Error::TimeoutError) && !exception.error_number
162+
if exception.is_a?(::Mysql2::Error::TimeoutError) && !exception.error_number
163163
ActiveRecord::AdapterTimeout.new(message, sql: sql, binds: binds)
164-
elsif exception.is_a?(Mysql2::Error::ConnectionError)
164+
elsif exception.is_a?(::Mysql2::Error::ConnectionError)
165165
if exception.message.match?(/MySQL client is not connected/i)
166166
ActiveRecord::ConnectionNotEstablished.new(exception)
167167
else

0 commit comments

Comments
 (0)