diff options
| author | François Freitag <mail@franek.fr> | 2017-01-13 22:36:25 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-01-16 09:12:23 -0500 |
| commit | 05bdf4f44dc80ba2481699860fa0a73de80694ae (patch) | |
| tree | 77dd90a4fc2bf1bda24a46b1c891dfdfd9bc8a69 | |
| parent | 1f10c3994cf3b54749c5a541896f4ac28ea694fa (diff) | |
Refs #16614 -- Called _prepare_cursor() on every created cursor.
| -rw-r--r-- | django/db/backends/base/base.py | 4 | ||||
| -rw-r--r-- | django/db/backends/postgresql/base.py | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py index 9c35ca7e47..c50cf5266a 100644 --- a/django/db/backends/base/base.py +++ b/django/db/backends/base/base.py @@ -228,7 +228,7 @@ class BaseDatabaseWrapper(object): def _cursor(self, name=None): self.ensure_connection() with self.wrap_database_errors: - return self.create_cursor(name) + return self._prepare_cursor(self.create_cursor(name)) def _commit(self): if self.connection is not None: @@ -251,7 +251,7 @@ class BaseDatabaseWrapper(object): """ Creates a cursor, opening a connection if necessary. """ - return self._prepare_cursor(self._cursor()) + return self._cursor() def commit(self): """ diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 91dee6a722..c40a67b2e1 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -223,14 +223,13 @@ class DatabaseWrapper(BaseDatabaseWrapper): def chunked_cursor(self): self._named_cursor_idx += 1 - db_cursor = self._cursor( + return self._cursor( name='_django_curs_%d_%d' % ( # Avoid reusing name in other threads threading.current_thread().ident, self._named_cursor_idx, ) ) - return self._prepare_cursor(db_cursor) def _set_autocommit(self, autocommit): with self.wrap_database_errors: |
