diff options
author | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-05-03 00:33:39 +0200 |
---|---|---|
committer | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-05-03 00:33:39 +0200 |
commit | b5824a4d04893077efe0dfe5ce61b3d666d64e99 (patch) | |
tree | 844e96c4a721af895e7a9d7b80b3228677c34e39 | |
parent | e30f068d658e5e7e038272e11590f0dee851da4a (diff) | |
download | rails-b5824a4d04893077efe0dfe5ce61b3d666d64e99.tar.gz rails-b5824a4d04893077efe0dfe5ce61b3d666d64e99.tar.bz2 rails-b5824a4d04893077efe0dfe5ce61b3d666d64e99.zip |
favor collect over each in mysql* adapters
-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 |