Author: russellm Date: 2010-02-11 06:21:46 -0600 (Thu, 11 Feb 2010) New Revision: 12410
Modified: django/trunk/django/core/cache/backends/db.py django/trunk/django/core/management/commands/createcachetable.py django/trunk/tests/regressiontests/cache/tests.py Log: Fixed #11623 -- Corrected table name quoting in db cache backend. Thanks to Fraser Nevett for the report and fix. Modified: django/trunk/django/core/cache/backends/db.py =================================================================== --- django/trunk/django/core/cache/backends/db.py 2010-02-11 12:10:11 UTC (rev 12409) +++ django/trunk/django/core/cache/backends/db.py 2010-02-11 12:21:46 UTC (rev 12410) @@ -12,7 +12,7 @@ class CacheClass(BaseCache): def __init__(self, table, params): BaseCache.__init__(self, params) - self._table = table + self._table = connection.ops.quote_name(table) max_entries = params.get('max_entries', 300) try: self._max_entries = int(max_entries) Modified: django/trunk/django/core/management/commands/createcachetable.py =================================================================== --- django/trunk/django/core/management/commands/createcachetable.py 2010-02-11 12:10:11 UTC (rev 12409) +++ django/trunk/django/core/management/commands/createcachetable.py 2010-02-11 12:21:46 UTC (rev 12410) @@ -38,8 +38,8 @@ field_output.append("UNIQUE") if f.db_index: unique = f.unique and "UNIQUE " or "" - index_output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \ - (unique, tablename, f.name, qn(tablename), + index_output.append("CREATE %sINDEX %s ON %s (%s);" % \ + (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), qn(f.name))) table_output.append(" ".join(field_output)) full_statement = ["CREATE TABLE %s (" % qn(tablename)] Modified: django/trunk/tests/regressiontests/cache/tests.py =================================================================== --- django/trunk/tests/regressiontests/cache/tests.py 2010-02-11 12:10:11 UTC (rev 12409) +++ django/trunk/tests/regressiontests/cache/tests.py 2010-02-11 12:21:46 UTC (rev 12410) @@ -342,13 +342,15 @@ class DBCacheTests(unittest.TestCase, BaseCacheTests): def setUp(self): - management.call_command('createcachetable', 'test_cache_table', verbosity=0, interactive=False) - self.cache = get_cache('db://test_cache_table') + # Spaces are used in the table name to ensure quoting/escaping is working + self._table_name = 'test cache table' + management.call_command('createcachetable', self._table_name, verbosity=0, interactive=False) + self.cache = get_cache('db://%s' % self._table_name) def tearDown(self): from django.db import connection cursor = connection.cursor() - cursor.execute('DROP TABLE test_cache_table') + cursor.execute('DROP TABLE %s' % connection.ops.quote_name(self._table_name)) class LocMemCacheTests(unittest.TestCase, BaseCacheTests): def setUp(self): -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.