Class: ActiveRecord::ConnectionAdapters::Mysql2LegacyDBAdapter

Inherits:
Mysql2Adapter
  • Object
show all
Defined in:
lib/active_record/connection_adapters/mysql2legacydb_adapter.rb

Instance Method Summary collapse

Instance Method Details

#columns(table_name, name = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 24

def columns(table_name, name = nil)
  sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}"
  columns = []
  result = execute(sql, :skip_logging)
  result.each(:symbolize_keys => true, :as => :hash) { |field|
    columns << Mysql2Column.new(legacy_to_new(field[:Field]), field[:Default], field[:Type], field[:Null] == "YES")
  }
  columns
end

#quote_column_name_with_translation(name) ⇒ Object



39
40
41
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 39

def quote_column_name_with_translation(name)
  quote_column_name_without_translation(new_to_legacy(name))
end

#quote_table_name_with_translation(name) ⇒ Object



44
45
46
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 44

def quote_table_name_with_translation(name)
  quote_table_name_without_translation(new_to_legacy(name))
end

#select_with_translation(sql, name = nil) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 49

def select_with_translation(sql, name = nil)
  select_without_translation(sql, name).collect { |row|
    translated = {}
    row.each { |key,val|
      translated[legacy_to_new(key)] = val
    }
    translated
  }
end

#tables_with_translationObject



34
35
36
# File 'lib/active_record/connection_adapters/mysql2legacydb_adapter.rb', line 34

def tables_with_translation
  tables_without_translation.map {|table| legacy_to_new(table) }
end