Class: ActiveRecord::ConnectionAdapters::MysqlAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::MysqlAdapter
- Defined in:
- lib/adapter_extensions/connection_adapters/mysql_adapter.rb
Overview
Adds new functionality to ActiveRecord MysqlAdapter.
Instance Method Summary collapse
-
#add_select_into_table(new_table_name, sql_query) ⇒ Object
Inserts an INTO table_name clause to the sql_query.
-
#copy_table(old_table_name, new_table_name) ⇒ Object
Copy the specified table.
- #support_select_into_table? ⇒ Boolean
Methods inherited from AbstractAdapter
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
7 8 9 |
# File 'lib/adapter_extensions/connection_adapters/mysql_adapter.rb', line 7 def support_select_into_table? true end |