Ticket #11623: db-cache-quoting.diff
File db-cache-quoting.diff, 2.5 KB (added by , 15 years ago) |
---|
-
django/core/cache/backends/db.py
12 12 class CacheClass(BaseCache): 13 13 def __init__(self, table, params): 14 14 BaseCache.__init__(self, params) 15 self._table = table15 self._table = connection.ops.quote_name(table) 16 16 max_entries = params.get('max_entries', 300) 17 17 try: 18 18 self._max_entries = int(max_entries) -
django/core/management/commands/createcachetable.py
27 27 field_output.append("UNIQUE") 28 28 if f.db_index: 29 29 unique = f.unique and "UNIQUE " or "" 30 index_output.append("CREATE %sINDEX %s _%sON %s (%s);" % \31 (unique, tablename, f.name, qn(tablename),30 index_output.append("CREATE %sINDEX %s ON %s (%s);" % \ 31 (unique, qn('%s_%s' % (tablename, f.name)), qn(tablename), 32 32 qn(f.name))) 33 33 table_output.append(" ".join(field_output)) 34 34 full_statement = ["CREATE TABLE %s (" % qn(tablename)] -
tests/regressiontests/cache/tests.py
238 238 239 239 class DBCacheTests(unittest.TestCase, BaseCacheTests): 240 240 def setUp(self): 241 management.call_command('createcachetable', 'test_cache_table', verbosity=0, interactive=False) 242 self.cache = get_cache('db://test_cache_table') 241 # Spaces are used in the table name to ensure quoting/escaping is working 242 self._table_name = 'test cache table' 243 management.call_command('createcachetable', self._table_name, verbosity=0, interactive=False) 244 self.cache = get_cache('db://%s' % self._table_name) 243 245 244 246 def tearDown(self): 245 247 from django.db import connection 246 248 cursor = connection.cursor() 247 cursor.execute('DROP TABLE test_cache_table');249 cursor.execute('DROP TABLE %s' % connection.ops.quote_name(self._table_name)); 248 250 249 251 class LocMemCacheTests(unittest.TestCase, BaseCacheTests): 250 252 def setUp(self):