mirror of
https://github.com/django/django.git
synced 2025-07-12 15:55:13 +00:00
Fixed #30148 -- Logged COPY ... TO statements in connection.queries on PostgreSQL.
This commit is contained in:
parent
f7408b49a5
commit
673fe2e3ec
3 changed files with 32 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
|||
import unittest
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import DatabaseError, connection, connections
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
|
||||
@unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL tests')
|
||||
|
@ -176,3 +177,15 @@ class Tests(TestCase):
|
|||
self.assertEqual(psycopg2_version(), (4, 2, 1))
|
||||
with mock.patch('psycopg2.__version__', '4.2b0.dev1 (dt dec pq3 ext lo64)'):
|
||||
self.assertEqual(psycopg2_version(), (4, 2))
|
||||
|
||||
@override_settings(DEBUG=True)
|
||||
def test_copy_cursors(self):
|
||||
out = StringIO()
|
||||
copy_expert_sql = 'COPY django_session TO STDOUT (FORMAT CSV, HEADER)'
|
||||
with connection.cursor() as cursor:
|
||||
cursor.copy_expert(copy_expert_sql, out)
|
||||
cursor.copy_to(out, 'django_session')
|
||||
self.assertEqual(
|
||||
[q['sql'] for q in connection.queries],
|
||||
[copy_expert_sql, 'COPY django_session TO STDOUT'],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue