Skip to content

Commit

Permalink
Merge pull request #370 from joshk/unrolled_map.
Browse files Browse the repository at this point in the history
favor map over each in mysql* adapters
  • Loading branch information
tenderlove committed May 2, 2011
2 parents 81cfbf4 + b5824a4 commit fa77665
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fa77665

Please sign in to comment.