diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-02 15:44:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-02 15:44:57 -0700 |
commit | fa77665a342b2486760c69007af4352cb40aae1e (patch) | |
tree | 5a5fbf6d669e77720b2598bb8a458b9d4f5317b6 /activerecord | |
parent | 81cfbf4146d3c5a58054b64112b8ce196f2fc061 (diff) | |
parent | b5824a4d04893077efe0dfe5ce61b3d666d64e99 (diff) | |
download | rails-fa77665a342b2486760c69007af4352cb40aae1e.tar.gz rails-fa77665a342b2486760c69007af4352cb40aae1e.tar.bz2 rails-fa77665a342b2486760c69007af4352cb40aae1e.zip |
Merge pull request #370 from joshk/unrolled_map.
favor map over each in mysql* adapters
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 |