summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/backends/__init__.py7
-rw-r--r--django/db/backends/oracle/base.py10
-rw-r--r--tests/admin_views/tests.py13
3 files changed, 14 insertions, 16 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 39628e76fc..f4f2ba2fe0 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -74,6 +74,10 @@ class BaseDatabaseWrapper(object):
self._thread_ident = thread.get_ident()
@property
+ def queries_logged(self):
+ return self.use_debug_cursor or settings.DEBUG
+
+ @property
def queries(self):
if len(self.queries_log) == self.queries_log.maxlen:
warnings.warn(
@@ -156,7 +160,7 @@ class BaseDatabaseWrapper(object):
Creates a cursor, opening a connection if necessary.
"""
self.validate_thread_sharing()
- if self.use_debug_cursor or settings.DEBUG:
+ if self.queries_logged:
cursor = self.make_debug_cursor(self._cursor())
else:
cursor = self.make_cursor(self._cursor())
@@ -493,7 +497,6 @@ class BaseDatabaseFeatures(object):
can_return_id_from_insert = False
has_bulk_insert = False
uses_savepoints = False
- can_release_savepoints = True
can_combine_inserts_with_and_without_auto_increment_pk = False
# If True, don't use integer foreign keys referring to, e.g., positive
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index f7790415db..b0b9a5f5a1 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -96,7 +96,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
needs_datetime_string_cast = False
interprets_empty_strings_as_nulls = True
uses_savepoints = True
- can_release_savepoints = False
has_select_for_update = True
has_select_for_update_nowait = True
can_return_id_from_insert = True
@@ -691,9 +690,14 @@ class DatabaseWrapper(BaseDatabaseWrapper):
"Returns a new instance of this backend's SchemaEditor"
return DatabaseSchemaEditor(self, *args, **kwargs)
- # Oracle doesn't support savepoint commits. Ignore them.
+ # Oracle doesn't support releasing savepoints. But we fake them when query
+ # logging is enabled to keep query counts consistent with other backends.
def _savepoint_commit(self, sid):
- pass
+ if self.queries_logged:
+ self.queries_log.append({
+ 'sql': '-- RELEASE SAVEPOINT %s (faked)' % self.ops.quote_name(sid),
+ 'time': '0.000',
+ })
def _set_autocommit(self, autocommit):
with self.wrap_database_errors:
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 4b08956936..82cabc1cfb 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -3960,11 +3960,7 @@ class UserAdminTest(TestCase):
# Don't depend on a warm cache, see #17377.
ContentType.objects.clear_cache()
- expected_queries = 10
- if not connection.features.can_release_savepoints:
- expected_queries -= 1
-
- with self.assertNumQueries(expected_queries):
+ with self.assertNumQueries(10):
response = self.client.get('/test_admin/admin/auth/user/%s/' % u.pk)
self.assertEqual(response.status_code, 200)
@@ -4001,12 +3997,7 @@ class GroupAdminTest(TestCase):
def test_group_permission_performance(self):
g = Group.objects.create(name="test_group")
-
- expected_queries = 8
- if not connection.features.can_release_savepoints:
- expected_queries -= 1
-
- with self.assertNumQueries(expected_queries):
+ with self.assertNumQueries(8):
response = self.client.get('/test_admin/admin/auth/group/%s/' % g.pk)
self.assertEqual(response.status_code, 200)