1
1
# frozen_string_literal: true
2
2
3
3
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"
5
5
6
6
gem "mysql2" , "~> 0.5"
7
7
require "mysql2"
@@ -28,12 +28,12 @@ class Mysql2Adapter < AbstractMysqlAdapter
28
28
29
29
ADAPTER_NAME = "Mysql2"
30
30
31
- include MySQL ::DatabaseStatements
31
+ include Mysql2 ::DatabaseStatements
32
32
33
33
class << self
34
34
def new_client ( config )
35
- Mysql2 ::Client . new ( config )
36
- rescue Mysql2 ::Error => error
35
+ :: Mysql2 ::Client . new ( config )
36
+ rescue :: Mysql2 ::Error => error
37
37
if error . error_number == ConnectionAdapters ::Mysql2Adapter ::ER_BAD_DB_ERROR
38
38
raise ActiveRecord ::NoDatabaseError . db_error ( config [ :database ] )
39
39
elsif error . error_number == ConnectionAdapters ::Mysql2Adapter ::ER_ACCESS_DENIED_ERROR
@@ -54,7 +54,7 @@ def initialize(...)
54
54
if @config [ :flags ] . kind_of? Array
55
55
@config [ :flags ] . push "FOUND_ROWS"
56
56
else
57
- @config [ :flags ] |= Mysql2 ::Client ::FOUND_ROWS
57
+ @config [ :flags ] |= :: Mysql2 ::Client ::FOUND_ROWS
58
58
end
59
59
60
60
@connection_parameters ||= @config
@@ -159,9 +159,9 @@ def get_full_version
159
159
end
160
160
161
161
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
163
163
ActiveRecord ::AdapterTimeout . new ( message , sql : sql , binds : binds )
164
- elsif exception . is_a? ( Mysql2 ::Error ::ConnectionError )
164
+ elsif exception . is_a? ( :: Mysql2 ::Error ::ConnectionError )
165
165
if exception . message . match? ( /MySQL client is not connected/i )
166
166
ActiveRecord ::ConnectionNotEstablished . new ( exception )
167
167
else
0 commit comments