diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index b6f838e49c..98a8dd6453 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -411,11 +411,9 @@ module ActiveRecord end def tables(name = nil) - tables = [] - execute("SHOW TABLES", 'SCHEMA').each do |field| - tables << field.first + execute("SHOW TABLES", 'SCHEMA').collect do |field| + field.first end - tables end def drop_table(table_name, options = {}) diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 862ce852e6..052ccde3d1 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -560,9 +560,8 @@ module ActiveRecord end def tables(name = nil, database = nil) #:nodoc: - tables = [] result = execute(["SHOW TABLES", database].compact.join(' IN '), 'SCHEMA') - result.each { |field| tables << field[0] } + tables = result.collect { |field| field[0] } result.free tables end @@ -607,9 +606,8 @@ module ActiveRecord # Returns an array of +MysqlColumn+ objects for the table specified by +table_name+. def columns(table_name, name = nil)#:nodoc: sql = "SHOW FIELDS FROM #{quote_table_name(table_name)}" - columns = [] result = execute(sql, 'SCHEMA') - result.each { |field| columns << MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") } + columns = result.collect { |field| MysqlColumn.new(field[0], field[4], field[1], field[2] == "YES") } result.free columns end |