Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
673fe2e3
Kaydet (Commit)
673fe2e3
authored
Nis 25, 2019
tarafından
kingbuzzman
Kaydeden (comit)
Mariusz Felisiak
Nis 29, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30148 -- Logged COPY ... TO statements in connection.queries on PostgreSQL.
üst
f7408b49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
base.py
django/db/backends/postgresql/base.py
+16
-0
3.0.txt
docs/releases/3.0.txt
+2
-0
tests.py
tests/backends/postgresql/tests.py
+14
-1
No files found.
django/db/backends/postgresql/base.py
Dosyayı görüntüle @
673fe2e3
...
@@ -11,6 +11,9 @@ from django.conf import settings
...
@@ -11,6 +11,9 @@ from django.conf import settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
connections
from
django.db
import
connections
from
django.db.backends.base.base
import
BaseDatabaseWrapper
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.db.utils
import
DatabaseError
as
WrappedDatabaseError
from
django.utils.functional
import
cached_property
from
django.utils.functional
import
cached_property
from
django.utils.safestring
import
SafeString
from
django.utils.safestring
import
SafeString
...
@@ -281,3 +284,16 @@ class DatabaseWrapper(BaseDatabaseWrapper):
...
@@ -281,3 +284,16 @@ class DatabaseWrapper(BaseDatabaseWrapper):
def
pg_version
(
self
):
def
pg_version
(
self
):
with
self
.
temporary_connection
():
with
self
.
temporary_connection
():
return
self
.
connection
.
server_version
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
)
docs/releases/3.0.txt
Dosyayı görüntüle @
673fe2e3
...
@@ -201,6 +201,8 @@ Models
...
@@ -201,6 +201,8 @@ Models
:class:`~django.db.models.functions.Trunc` database functions determines the
:class:`~django.db.models.functions.Trunc` database functions determines the
treatment of nonexistent and ambiguous datetimes.
treatment of nonexistent and ambiguous datetimes.
* ``connection.queries`` now shows ``COPY … TO`` statements on PostgreSQL.
Requests and Responses
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/backends/postgresql/tests.py
Dosyayı görüntüle @
673fe2e3
import
unittest
import
unittest
from
io
import
StringIO
from
unittest
import
mock
from
unittest
import
mock
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
DatabaseError
,
connection
,
connections
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'
)
@unittest.skipUnless
(
connection
.
vendor
==
'postgresql'
,
'PostgreSQL tests'
)
...
@@ -176,3 +177,15 @@ class Tests(TestCase):
...
@@ -176,3 +177,15 @@ class Tests(TestCase):
self
.
assertEqual
(
psycopg2_version
(),
(
4
,
2
,
1
))
self
.
assertEqual
(
psycopg2_version
(),
(
4
,
2
,
1
))
with
mock
.
patch
(
'psycopg2.__version__'
,
'4.2b0.dev1 (dt dec pq3 ext lo64)'
):
with
mock
.
patch
(
'psycopg2.__version__'
,
'4.2b0.dev1 (dt dec pq3 ext lo64)'
):
self
.
assertEqual
(
psycopg2_version
(),
(
4
,
2
))
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'
],
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment