Class: ActiveRecord::ConnectionAdapters::MysqlAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/adapter_extensions/connection_adapters/mysql_adapter.rb

Overview

Adds new functionality to ActiveRecord MysqlAdapter.

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#bulk_load, #truncate

Instance Method Details

#add_select_into_table(new_table_name, sql_query) ⇒ Object

Inserts an INTO table_name clause to the sql_query.



12
13
14
# File 'lib/adapter_extensions/connection_adapters/mysql_adapter.rb', line 12

def add_select_into_table(new_table_name, sql_query)
  "CREATE TABLE #{new_table_name} " + sql_query
end

#copy_table(old_table_name, new_table_name) ⇒ Object

Copy the specified table.



17
18
19
20
21
22
# File 'lib/adapter_extensions/connection_adapters/mysql_adapter.rb', line 17

def copy_table(old_table_name, new_table_name)
  transaction do
    execute "CREATE TABLE #{new_table_name} LIKE #{old_table_name}"
    execute "INSERT INTO #{new_table_name} SELECT * FROM #{old_table_name}"
  end
end

#support_select_into_table?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/adapter_extensions/connection_adapters/mysql_adapter.rb', line 7

def support_select_into_table?
  true
end