Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Defined in:
lib/adapter_extensions/connection_adapters/postgresql_adapter.rb

Overview

Adds new functionality to ActiveRecord PostgreSQLAdapter.

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.



11
12
13
# File 'lib/adapter_extensions/connection_adapters/postgresql_adapter.rb', line 11

def add_select_into_table(new_table_name, sql_query)
  sql_query.sub(/FROM/i, "INTO #{new_table_name} FROM")
end

#copy_table(old_table_name, new_table_name) ⇒ Object

Copy the specified table.



16
17
18
# File 'lib/adapter_extensions/connection_adapters/postgresql_adapter.rb', line 16

def copy_table(old_table_name, new_table_name)
  execute add_select_into_table(new_table_name, "SELECT * FROM #{old_table_name}")
end

#support_select_into_table?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/adapter_extensions/connection_adapters/postgresql_adapter.rb', line 6

def support_select_into_table?
  true
end