summaryrefslogtreecommitdiff
path: root/django/core/cache
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-02-11 13:12:38 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-02-11 13:12:38 +0000
commitf764d7ffb1c0681448675d7ff618042e722b68f6 (patch)
treeab1a10547bba0e38b29d7aca636b1628078b199d /django/core/cache
parentd4a34b5508a73c47d9e7220ee92dd7b8fb9e4262 (diff)
[1.1.X] Fixed #11483 -- Modified db cache backend to use db backend functions for date conversion, avoiding problems under Jython. Thanks to Leo Soto for the report and patch.
Merge of r12411 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12415 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/cache')
-rw-r--r--django/core/cache/backends/db.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index 4a9bc75a11..0cdccbad16 100644
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -60,9 +60,11 @@ class CacheClass(BaseCache):
result = cursor.fetchone()
if result and (mode == 'set' or
(mode == 'add' and result[1] < now)):
- cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE cache_key = %%s" % self._table, [encoded, str(exp), key])
+ cursor.execute("UPDATE %s SET value = %%s, expires = %%s WHERE cache_key = %%s" % self._table,
+ [encoded, connection.ops.value_to_db_datetime(exp), key])
else:
- cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table, [key, encoded, str(exp)])
+ cursor.execute("INSERT INTO %s (cache_key, value, expires) VALUES (%%s, %%s, %%s)" % self._table,
+ [key, encoded, connection.ops.value_to_db_datetime(exp)])
except DatabaseError:
# To be threadsafe, updates/inserts are allowed to fail silently
transaction.rollback_unless_managed()
@@ -86,7 +88,8 @@ class CacheClass(BaseCache):
if self._cull_frequency == 0:
cursor.execute("DELETE FROM %s" % self._table)
else:
- cursor.execute("DELETE FROM %s WHERE expires < %%s" % self._table, [str(now)])
+ cursor.execute("DELETE FROM %s WHERE expires < %%s" % self._table,
+ [connection.ops.value_to_db_datetime(now)])
cursor.execute("SELECT COUNT(*) FROM %s" % self._table)
num = cursor.fetchone()[0]
if num > self._max_entries: