aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
diff options
context:
space:
mode:
authorDamir Zekic <damirz@gmail.com>2012-07-06 13:03:49 +0200
committerDamir Zekic <damirz@gmail.com>2012-07-06 15:01:55 +0200
commit75b340d1a4bcf2f1233fb65a15ff6b8059e2230e (patch)
treec415d4519556d20665b7f8409be2f0345a6b3e16 /activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
parent8ce61a366474b20368f60eb1c7bf31c3b7297873 (diff)
downloadrails-75b340d1a4bcf2f1233fb65a15ff6b8059e2230e.tar.gz
rails-75b340d1a4bcf2f1233fb65a15ff6b8059e2230e.tar.bz2
rails-75b340d1a4bcf2f1233fb65a15ff6b8059e2230e.zip
Disable query cache for lock queries
Fixes #867
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
index 3b4537aab4..a6e16da730 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -56,7 +56,7 @@ module ActiveRecord
end
def select_all(arel, name = nil, binds = [])
- if @query_cache_enabled
+ if @query_cache_enabled && !locked?(arel)
sql = to_sql(arel, binds)
cache_sql(sql, binds) { super(sql, name, binds) }
else
@@ -83,6 +83,14 @@ module ActiveRecord
result.collect { |row| row.dup }
end
end
+
+ def locked?(arel)
+ if arel.respond_to?(:locked)
+ arel.locked
+ else
+ false
+ end
+ end
end
end
end