diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index ebe8875..3af6f1f 100644
|
a
|
b
|
class BaseDatabaseOperations(object):
|
| 589 | 589 | to_unicode = lambda s: force_unicode(s, strings_only=True, errors='replace') |
| 590 | 590 | if isinstance(params, (list, tuple)): |
| 591 | 591 | u_params = tuple([to_unicode(val) for val in params]) |
| | 592 | elif params is None: |
| | 593 | u_params = () |
| 592 | 594 | else: |
| 593 | 595 | u_params = dict([(to_unicode(k), to_unicode(v)) for k, v in params.items()]) |
| 594 | 596 | |
diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index b0463b7..ec949eb 100644
|
a
|
b
|
class CursorWrapper(object):
|
| 30 | 30 | |
| 31 | 31 | class CursorDebugWrapper(CursorWrapper): |
| 32 | 32 | |
| 33 | | def execute(self, sql, params=()): |
| | 33 | def execute(self, sql, params=None): |
| 34 | 34 | start = time() |
| 35 | 35 | try: |
| 36 | | return self.cursor.execute(sql, params) |
| | 36 | if params is None: |
| | 37 | # params default might be backend specific |
| | 38 | return self.cursor.execute(sql) |
| | 39 | else: |
| | 40 | return self.cursor.execute(sql, params) |
| 37 | 41 | finally: |
| 38 | 42 | stop = time() |
| 39 | 43 | duration = stop - start |
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
index 436da8c..5ff2c60 100644
|
a
|
b
|
from django.db.backends.signals import connection_created
|
| 14 | 14 | from django.db.backends.postgresql_psycopg2 import version as pg_version |
| 15 | 15 | from django.db.utils import ConnectionHandler, DatabaseError, load_backend |
| 16 | 16 | from django.test import TestCase, skipUnlessDBFeature, TransactionTestCase |
| | 17 | from django.test.utils import override_settings |
| 17 | 18 | from django.utils import unittest |
| 18 | 19 | |
| 19 | 20 | from . import models |
| … |
… |
class ConnectionCreatedSignalTest(TestCase):
|
| 294 | 295 | |
| 295 | 296 | |
| 296 | 297 | class EscapingChecks(TestCase): |
| 297 | | |
| | 298 | """ Each test is run once with normal cursor, and once with |
| | 299 | CursorDebugWrapper activated by setting DEBUG to True |
| | 300 | """ |
| 298 | 301 | @unittest.skipUnless(connection.vendor == 'sqlite', |
| 299 | 302 | "This is a sqlite-specific issue") |
| 300 | 303 | def test_parameter_escaping(self): |
| … |
… |
class EscapingChecks(TestCase):
|
| 306 | 309 | # response should be an non-zero integer |
| 307 | 310 | self.assertTrue(int(response)) |
| 308 | 311 | |
| | 312 | @unittest.skipUnless(connection.vendor == 'sqlite', |
| | 313 | "This is a sqlite-specific issue") |
| | 314 | @override_settings(DEBUG=True) |
| | 315 | def test_parameter_escaping_debug(self): |
| | 316 | self.test_parameter_escaping() |
| | 317 | |
| | 318 | @unittest.skipUnless(connection.vendor == 'mysql', |
| | 319 | "This is a mysql-specific test") |
| | 320 | def test_parameter_escaping_mysql(self): |
| | 321 | cursor = connection.cursor() |
| | 322 | response = cursor.execute("SELECT DATE_FORMAT(NOW(), '%%Y-%%m-%%e')") |
| | 323 | self.assertTrue(len(cursor.fetchall()[0][0]) > 6) |
| | 324 | |
| | 325 | @unittest.skipUnless(connection.vendor == 'mysql', |
| | 326 | "This is a mysql-specific test") |
| | 327 | @override_settings(DEBUG=True) |
| | 328 | def test_parameter_escaping_mysql_debug(self): |
| | 329 | self.test_parameter_escaping_mysql() |
| | 330 | |
| 309 | 331 | |
| 310 | 332 | class BackendTestCase(TestCase): |
| 311 | 333 | def test_cursor_executemany(self): |