提交 28948879 编写于 作者: J Jeremy Kemper

Explicitly require active_record/query_cache before using it.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7419 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 f1b12b62
*SVN* *SVN*
* Explicitly require active_record/query_cache before using it. [Jeremy Kemper]
* Fix layout overriding response status. #9476 [lotswholetime] * Fix layout overriding response status. #9476 [lotswholetime]
* Add fieldset_tag for generating fieldsets, closes #9477. [djanowski] * Add fieldset_tag for generating fieldsets, closes #9477. [djanowski]
......
...@@ -12,7 +12,10 @@ module ActionController #:nodoc: ...@@ -12,7 +12,10 @@ module ActionController #:nodoc:
module Caching module Caching
def self.included(base) #:nodoc: def self.included(base) #:nodoc:
base.send(:include, Pages, Actions, Fragments) base.send(:include, Pages, Actions, Fragments)
base.send(:include, Sweeping, SqlCache) if defined?(ActiveRecord) if defined?(ActiveRecord)
require 'active_record/query_cache'
base.send(:include, Sweeping, SqlCache)
end
base.class_eval do base.class_eval do
@@perform_caching = true @@perform_caching = true
...@@ -656,20 +659,19 @@ def method_missing(method, *arguments) ...@@ -656,20 +659,19 @@ def method_missing(method, *arguments)
end end
end end
end end
if defined?(ActiveRecord) module SqlCache
module SqlCache def self.included(base) #:nodoc:
def self.included(base) #:nodoc: if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?(:cache)
base.alias_method_chain :perform_action, :caching base.alias_method_chain :perform_action, :caching
end end
end
def perform_action_with_caching
ActiveRecord::Base.cache do def perform_action_with_caching
perform_action_without_caching ActiveRecord::Base.cache do
end perform_action_without_caching
end end
end end
end end
end end
end end
*SVN* *SVN*
* Explicitly require active_record/query_cache before using it. [Jeremy Kemper]
* Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick, marclove] * Fix bug where unserializing an attribute attempts to modify a frozen @attributes hash for a deleted record. [Rick, marclove]
* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper] * Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper]
......
...@@ -75,5 +75,4 @@ ...@@ -75,5 +75,4 @@
require 'active_record/connection_adapters/abstract_adapter' require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/query_cache'
require 'active_record/schema_dumper' require 'active_record/schema_dumper'
...@@ -62,7 +62,7 @@ def cache(sql) ...@@ -62,7 +62,7 @@ def cache(sql)
case result case result
when Array when Array
result.collect { |row| row.dup } result.collect { |row| row.dup }
when Numeric, NilClass, FalseClass when Fixnum, NilClass, FalseClass
result result
else else
result.dup result.dup
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
require 'fixtures/task' require 'fixtures/task'
require 'fixtures/course' require 'fixtures/course'
require 'active_record/query_cache'
class QueryCacheTest < Test::Unit::TestCase class QueryCacheTest < Test::Unit::TestCase
fixtures :tasks fixtures :tasks
...@@ -117,4 +119,4 @@ def test_new_save ...@@ -117,4 +119,4 @@ def test_new_save
end end
end end
end end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册