提交 9c7e2e41 编写于 作者: A Aaron Patterson

find_one uses prepared statement cache

上级 5abebfb5
......@@ -718,6 +718,7 @@ def column_methods_hash #: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
......
......@@ -288,7 +288,12 @@ def find_with_ids(*ids)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册