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
6b3d2920
Kaydet (Commit)
6b3d2920
authored
Ock 18, 2018
tarafından
priyanshsaxena
Kaydeden (comit)
Tim Graham
Nis 28, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29015 -- Added an exception if the PostgreSQL database name is too long.
üst
6d1f5769
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
base.py
django/db/backends/postgresql/base.py
+6
-0
tests.py
tests/backends/postgresql/tests.py
+13
-0
No files found.
django/db/backends/postgresql/base.py
Dosyayı görüntüle @
6b3d2920
...
...
@@ -149,6 +149,12 @@ class DatabaseWrapper(BaseDatabaseWrapper):
raise
ImproperlyConfigured
(
"settings.DATABASES is improperly configured. "
"Please supply the NAME value."
)
if
len
(
settings_dict
[
'NAME'
]
or
''
)
>
self
.
ops
.
max_name_length
():
raise
ImproperlyConfigured
(
'Database names longer than
%
d characters are not supported by '
'PostgreSQL. Supply a shorter NAME in settings.DATABASES.'
%
self
.
ops
.
max_name_length
()
)
conn_params
=
{
'database'
:
settings_dict
[
'NAME'
]
or
'postgres'
,
**
settings_dict
[
'OPTIONS'
],
...
...
tests/backends/postgresql/tests.py
Dosyayı görüntüle @
6b3d2920
...
...
@@ -2,6 +2,7 @@ import unittest
import
warnings
from
unittest
import
mock
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
DatabaseError
,
connection
,
connections
from
django.test
import
TestCase
...
...
@@ -39,6 +40,18 @@ class Tests(TestCase):
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
w
[
0
]
.
message
.
__class__
,
RuntimeWarning
)
def
test_database_name_too_long
(
self
):
from
django.db.backends.postgresql.base
import
DatabaseWrapper
settings
=
connection
.
settings_dict
.
copy
()
max_name_length
=
connection
.
ops
.
max_name_length
()
settings
[
'NAME'
]
=
'a'
+
(
max_name_length
*
'a'
)
msg
=
(
'Database names longer than
%
d characters are not supported by '
'PostgreSQL. Supply a shorter NAME in settings.DATABASES.'
)
%
max_name_length
with
self
.
assertRaisesMessage
(
ImproperlyConfigured
,
msg
):
DatabaseWrapper
(
settings
)
.
get_connection_params
()
def
test_connect_and_rollback
(
self
):
"""
PostgreSQL shouldn't roll back SET TIME ZONE, even if the first
...
...
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