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 | |
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')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index db7f9b7974..492a807ff5 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -718,6 +718,7 @@ module ActiveRecord #:nodoc: # end # end def reset_column_information + connection.reset! undefine_attribute_methods @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @inheritance_column = nil @arel_engine = @relation = @arel_table = nil 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 |