aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2015-05-05 15:35:42 +0900
committerRyuta Kamizono <kamipo@gmail.com>2015-05-05 15:35:42 +0900
commit7bfc6ea1ef6963eeff39d1cdd4852a822371b528 (patch)
treecd13bb86555b9e769adc30d0c9a0888784950985 /activerecord/lib
parent984a4db3c35af4cd0e2191775b00f850f95ae66c (diff)
downloadrails-7bfc6ea1ef6963eeff39d1cdd4852a822371b528.tar.gz
rails-7bfc6ea1ef6963eeff39d1cdd4852a822371b528.tar.bz2
rails-7bfc6ea1ef6963eeff39d1cdd4852a822371b528.zip
Use `select_rows` instead of `select_one` in `select_value`
`select_one` create `ActiveRecord::Result` instance. It is better to use `select_rows` instead of `select_one` for performance.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
index 42c794c828..431fe25501 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -40,8 +40,9 @@ module ActiveRecord
# Returns a single value from a record
def select_value(arel, name = nil, binds = [])
- if result = select_one(arel, name, binds)
- result.values.first
+ arel, binds = binds_from_relation arel, binds
+ if result = select_rows(to_sql(arel, binds), name, binds).first
+ result.first
end
end