diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-12 17:04:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:08 -0700 |
commit | 9c7e2e4117018ef462efc1e06a45b046b466789f (patch) | |
tree | b08dc8d363a8504186a52fda3f9488478fd8e8b6 /activerecord/lib/active_record/relation | |
parent | 5abebfb569dcf69847a473c337e07e25f88d63a4 (diff) | |
download | rails-9c7e2e4117018ef462efc1e06a45b046b466789f.tar.gz rails-9c7e2e4117018ef462efc1e06a45b046b466789f.tar.bz2 rails-9c7e2e4117018ef462efc1e06a45b046b466789f.zip |
find_one uses prepared statement cache
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index b763e22ec6..fe1ef2e2e3 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -288,7 +288,12 @@ module ActiveRecord def find_one(id) id = id.id if ActiveRecord::Base === id - record = where(primary_key.eq(id)).first + column = primary_key.column + + substitute = connection.substitute_for(column, @bind_values) + relation = where(primary_key.eq(substitute)) + relation.bind_values = [[column, id]] + record = relation.first unless record conditions = arel.where_sql |