diff options
author | Emilio Tagua <miloops@gmail.com> | 2011-04-03 20:09:00 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-04 10:48:12 +0200 |
commit | b35617235d43bdb32016a623044e7f4005879969 (patch) | |
tree | 6a007f2bf9678fa1c1c5c64c8980032934fbefb0 /activerecord/lib/active_record/relation | |
parent | 16e5d158c23af1c7ca2c7aa32d964db97cb9a4f7 (diff) | |
download | rails-b35617235d43bdb32016a623044e7f4005879969.tar.gz rails-b35617235d43bdb32016a623044e7f4005879969.tar.bz2 rails-b35617235d43bdb32016a623044e7f4005879969.zip |
Use IM when trying to load records using ID.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 8fa315bdf3..7fe6fe0ed0 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -309,6 +309,15 @@ module ActiveRecord def find_one(id) id = id.id if ActiveRecord::Base === id + if IdentityMap.enabled? && where_values.blank? && + limit_value.blank? && order_values.blank? && + includes_values.blank? && preload_values.blank? && + readonly_value.nil? && joins_values.blank? && + !@klass.locking_enabled? && + record = IdentityMap.get(@klass, id) + return record + end + column = columns_hash[primary_key] substitute = connection.substitute_for(column, @bind_values) |