aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-08 04:31:26 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-08 04:31:26 +0000
commit2894887925a3613f1ea9f81bd72ec1f51c3e06da (patch)
tree81e12dceaab6af0a2619e3486696ebaf155ed1c1
parentf1b12b62f48257054a416269f3bf465fb4a8d6e7 (diff)
downloadrails-2894887925a3613f1ea9f81bd72ec1f51c3e06da.tar.gz
rails-2894887925a3613f1ea9f81bd72ec1f51c3e06da.tar.bz2
rails-2894887925a3613f1ea9f81bd72ec1f51c3e06da.zip
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
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/caching.rb24
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record.rb1
-rw-r--r--activerecord/lib/active_record/query_cache.rb2
-rw-r--r--activerecord/test/query_cache_test.rb4
6 files changed, 21 insertions, 14 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index ac1c568a94..fdf6fd7e8c 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Explicitly require active_record/query_cache before using it. [Jeremy Kemper]
+
* Fix layout overriding response status. #9476 [lotswholetime]
* Add fieldset_tag for generating fieldsets, closes #9477. [djanowski]
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index 3434f5f9da..e6e42b9126 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -12,7 +12,10 @@ module ActionController #:nodoc:
module Caching
def self.included(base) #:nodoc:
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
@@perform_caching = true
@@ -656,20 +659,19 @@ module ActionController #:nodoc:
end
end
end
-
- if defined?(ActiveRecord)
- module SqlCache
- def self.included(base) #:nodoc:
+
+ module SqlCache
+ def self.included(base) #:nodoc:
+ if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?(:cache)
base.alias_method_chain :perform_action, :caching
end
-
- def perform_action_with_caching
- ActiveRecord::Base.cache do
- perform_action_without_caching
- end
+ end
+
+ def perform_action_with_caching
+ ActiveRecord::Base.cache do
+ perform_action_without_caching
end
end
end
-
end
end
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 768dfe93ac..8408b44672 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*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]
* Performance: absorb instantiate and initialize_with_callbacks into the Base methods. [Jeremy Kemper]
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 7dd89d86d0..9b391bf868 100755
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -75,5 +75,4 @@ end
require 'active_record/connection_adapters/abstract_adapter'
-require 'active_record/query_cache'
require 'active_record/schema_dumper'
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb
index e598de07e2..1b15f92284 100644
--- a/activerecord/lib/active_record/query_cache.rb
+++ b/activerecord/lib/active_record/query_cache.rb
@@ -62,7 +62,7 @@ module ActiveRecord
case result
when Array
result.collect { |row| row.dup }
- when Numeric, NilClass, FalseClass
+ when Fixnum, NilClass, FalseClass
result
else
result.dup
diff --git a/activerecord/test/query_cache_test.rb b/activerecord/test/query_cache_test.rb
index 8c8ae69776..d63df6141d 100644
--- a/activerecord/test/query_cache_test.rb
+++ b/activerecord/test/query_cache_test.rb
@@ -4,6 +4,8 @@ require 'fixtures/reply'
require 'fixtures/task'
require 'fixtures/course'
+require 'active_record/query_cache'
+
class QueryCacheTest < Test::Unit::TestCase
fixtures :tasks
@@ -117,4 +119,4 @@ class QueryCacheExpiryTest < Test::Unit::TestCase
end
end
-end \ No newline at end of file
+end