remove performance overrides of select_one, select_value, and select_values in the AR adapter for now

This commit is contained in:
Brian Lopez 2010-08-02 01:26:04 -07:00
parent 1086233cc3
commit 00ab233606
1 changed files with 27 additions and 22 deletions

View File

@ -264,28 +264,33 @@ module ActiveRecord
# DATABASE STATEMENTS ======================================
# Returns a record hash with the column names as keys and column values
# as values.
def select_one(sql, name = nil)
result = execute(sql, name)
result.each(:as => :hash) do |r|
return r
end
end
# Returns a single value from a record
def select_value(sql, name = nil)
result = execute(sql, name)
if first = result.first
first.first
end
end
# Returns an array of the values of the first column in a select:
# select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
def select_values(sql, name = nil)
execute(sql, name).map { |row| row.first }
end
# FIXME: re-enable the following once a "better" query_cache solution is in core
#
# The overrides below perform much better than the originals in AbstractAdapter
# because we're able to take advantage of mysql2's lazy-loading capabilities
#
# # Returns a record hash with the column names as keys and column values
# # as values.
# def select_one(sql, name = nil)
# result = execute(sql, name)
# result.each(:as => :hash) do |r|
# return r
# end
# end
#
# # Returns a single value from a record
# def select_value(sql, name = nil)
# result = execute(sql, name)
# if first = result.first
# first.first
# end
# end
#
# # Returns an array of the values of the first column in a select:
# # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
# def select_values(sql, name = nil)
# execute(sql, name).map { |row| row.first }
# end
# Returns an array of arrays containing the field values.
# Order is the same as that returned by +columns+.