Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

favor map over each in mysql* adapters #370

Merged
merged 1 commit into from

3 participants

@joshk

No description provided.

@dhh
Owner
dhh commented

I actually like #collect better. Mind updating to that? I'll apply then.

@joshk

Sure, one sec, found another couple of places, just running the tests

@joshk

updated :)

@tenderlove tenderlove merged commit fa77665 into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2011
  1. @joshk
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.