favor map over each in mysql* adapters #370

Merged
merged 1 commit into from May 2, 2011
Jump to file or symbol
Failed to load files and symbols.
+4 −8
Diff settings

Always

Just for now

@@ -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 = {})
@@ -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