Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #370 from joshk/unrolled_map.

favor map over each in mysql* adapters
  • Loading branch information...
commit fa77665a342b2486760c69007af4352cb40aae1e 2 parents 81cfbf4 + b5824a4
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -411,11 +411,9 @@ def collation
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 = {})
View
6 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -560,9 +560,8 @@ def collation
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 @@ def indexes(table_name, name = nil)#:nodoc:
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.