MySQL -> Mysql2 naming in AR adapter

This commit is contained in:
Brian Lopez 2010-07-20 09:14:37 -07:00
parent 9ab1c90d2b
commit 3ec92096ca

View File

@ -14,7 +14,7 @@ module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
class Mysql2Column < Column class Mysql2Column < Column
BOOL = "tinyint(1)".freeze BOOL = "tinyint(1)"
def extract_default(default) def extract_default(default)
if sql_type =~ /blob/i || type == :text if sql_type =~ /blob/i || type == :text
if default.blank? if default.blank?
@ -130,8 +130,8 @@ module ActiveRecord
cattr_accessor :emulate_booleans cattr_accessor :emulate_booleans
self.emulate_booleans = true self.emulate_booleans = true
ADAPTER_NAME = 'MySQL'.freeze ADAPTER_NAME = 'MySQL2'
PRIMARY = "PRIMARY".freeze PRIMARY = "PRIMARY"
LOST_CONNECTION_ERROR_MESSAGES = [ LOST_CONNECTION_ERROR_MESSAGES = [
"Server shutdown in progress", "Server shutdown in progress",
@ -139,10 +139,10 @@ module ActiveRecord
"Lost connection to MySQL server during query", "Lost connection to MySQL server during query",
"MySQL server has gone away" ] "MySQL server has gone away" ]
QUOTED_TRUE, QUOTED_FALSE = '1'.freeze, '0'.freeze QUOTED_TRUE, QUOTED_FALSE = '1', '0'
NATIVE_DATABASE_TYPES = { NATIVE_DATABASE_TYPES = {
:primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze, :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY",
:string => { :name => "varchar", :limit => 255 }, :string => { :name => "varchar", :limit => 255 },
:text => { :name => "text" }, :text => { :name => "text" },
:integer => { :name => "int", :limit => 4 }, :integer => { :name => "int", :limit => 4 },
@ -263,7 +263,7 @@ 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 MySQL::Result object. Note that you have to free the Result object after you're done using it. # 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)