cleanup connection handling in AR adapter, this should finally resolve GH#31
This commit is contained in:
parent
a878ba0272
commit
20ef2e5e27
|
@ -238,7 +238,8 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def reconnect!
|
def reconnect!
|
||||||
reset!
|
disconnect!
|
||||||
|
connect
|
||||||
end
|
end
|
||||||
|
|
||||||
def disconnect!
|
def disconnect!
|
||||||
|
@ -250,7 +251,12 @@ module ActiveRecord
|
||||||
|
|
||||||
def reset!
|
def reset!
|
||||||
disconnect!
|
disconnect!
|
||||||
@connection = Mysql2::Client.new(@config)
|
connect
|
||||||
|
end
|
||||||
|
|
||||||
|
# this is set to true in 2.3, but we don't want it to be
|
||||||
|
def requires_reloading?
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# DATABASE STATEMENTS ======================================
|
# DATABASE STATEMENTS ======================================
|
||||||
|
@ -263,7 +269,6 @@ module ActiveRecord
|
||||||
select(sql, name).map { |row| row.values }
|
select(sql, name).map { |row| row.values }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Executes a SQL query and returns a Mysql2::Result object. Note that you have to free the Result object after you're done using it.
|
|
||||||
def execute(sql, name = nil)
|
def execute(sql, name = nil)
|
||||||
if name == :skip_logging
|
if name == :skip_logging
|
||||||
@connection.query(sql)
|
@connection.query(sql)
|
||||||
|
@ -547,7 +552,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: implement error_number method on Mysql2::Exception
|
|
||||||
def translate_exception(exception, message)
|
def translate_exception(exception, message)
|
||||||
return super unless exception.respond_to?(:error_number)
|
return super unless exception.respond_to?(:error_number)
|
||||||
|
|
||||||
|
@ -563,7 +567,8 @@ module ActiveRecord
|
||||||
|
|
||||||
private
|
private
|
||||||
def connect
|
def connect
|
||||||
# no-op
|
@connection = Mysql2::Client.new(@config)
|
||||||
|
configure_connection
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_connection
|
def configure_connection
|
||||||
|
|
Loading…
Reference in New Issue