summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/base.py
diff options
context:
space:
mode:
authorkingbuzzman <buzzi.javier@gmail.com>2019-04-25 16:09:27 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-29 14:20:17 +0200
commit673fe2e3ec63614259e86e7a370b9d1e91fcc1e1 (patch)
tree19eb301459c0295a5cb0b5a8bb6abdeed8128ad0 /django/db/backends/postgresql/base.py
parentf7408b49a54d746db252ebc7176a67506d183a58 (diff)
downloaddjango-673fe2e3ec63614259e86e7a370b9d1e91fcc1e1.tar.gz
Fixed #30148 -- Logged COPY ... TO statements in connection.queries on PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r--django/db/backends/postgresql/base.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index 250691aeda..6f8e06fe23 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -11,6 +11,9 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import connections
from django.db.backends.base.base import BaseDatabaseWrapper
+from django.db.backends.utils import (
+ CursorDebugWrapper as BaseCursorDebugWrapper,
+)
from django.db.utils import DatabaseError as WrappedDatabaseError
from django.utils.functional import cached_property
from django.utils.safestring import SafeString
@@ -281,3 +284,16 @@ class DatabaseWrapper(BaseDatabaseWrapper):
def pg_version(self):
with self.temporary_connection():
return self.connection.server_version
+
+ def make_debug_cursor(self, cursor):
+ return CursorDebugWrapper(cursor, self)
+
+
+class CursorDebugWrapper(BaseCursorDebugWrapper):
+ def copy_expert(self, sql, file, *args):
+ with self.debug_sql(sql):
+ return self.cursor.copy_expert(sql, file, *args)
+
+ def copy_to(self, file, table, *args, **kwargs):
+ with self.debug_sql(sql='COPY %s TO STDOUT' % table):
+ return self.cursor.copy_to(file, table, *args, **kwargs)