提交 18bf3098 编写于 作者: J Jon Leighton

Cache column defaults on model. ~30% on Model.new due to avoiding repeatedly fetching connection.

上级 7b0edbb9
......@@ -782,7 +782,7 @@ def columns_hash
# Returns a hash where the keys are column names and the values are
# default values when instantiating the AR object for this table.
def column_defaults
connection.schema_cache.column_defaults[table_name]
@column_defaults ||= connection.schema_cache.column_defaults[table_name]
end
# Returns an array of column names as strings.
......@@ -841,7 +841,7 @@ def reset_column_information
undefine_attribute_methods
connection.schema_cache.clear_table_cache!(table_name) if table_exists?
@column_names = @content_columns = @dynamic_methods_hash = @inheritance_column = nil
@column_names = @content_columns = @column_defaults = @dynamic_methods_hash = @inheritance_column = nil
@arel_engine = @relation = nil
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册