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
391c450f
Kaydet (Commit)
391c450f
authored
Kas 30, 2016
tarafından
Adam Chainz
Kaydeden (comit)
Tim Graham
Ara 29, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #25415 -- Made MySQL backend skip field validation of unsupported models.
üst
00c7bfad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
validation.py
django/db/backends/mysql/validation.py
+25
-17
test_ordinary_fields.py
tests/invalid_models_tests/test_ordinary_fields.py
+1
-1
No files found.
django/db/backends/mysql/validation.py
Dosyayı görüntüle @
391c450f
...
...
@@ -32,25 +32,33 @@ class DatabaseValidation(BaseDatabaseValidation):
No character (varchar) fields can have a length exceeding 255
characters if they have a unique index on them.
"""
from
django.db
import
connection
errors
=
super
(
DatabaseValidation
,
self
)
.
check_field
(
field
,
**
kwargs
)
# Ignore any related fields.
if
getattr
(
field
,
'remote_field'
,
None
)
is
None
:
field_type
=
field
.
db_type
(
connection
)
# Ignore any non-concrete fields
if
field_type
is
None
:
return
errors
if
(
field_type
.
startswith
(
'varchar'
)
and
field
.
unique
and
(
field
.
max_length
is
None
or
int
(
field
.
max_length
)
>
255
)):
errors
.
append
(
checks
.
Error
(
'MySQL does not allow unique CharFields to have a max_length > 255.'
,
obj
=
field
,
id
=
'mysql.E001'
,
)
if
getattr
(
field
,
'remote_field'
,
None
):
return
errors
# Ignore fields with unsupported features.
db_supports_all_required_features
=
all
(
getattr
(
self
.
connection
.
features
,
feature
,
False
)
for
feature
in
field
.
model
.
_meta
.
required_db_features
)
if
not
db_supports_all_required_features
:
return
errors
field_type
=
field
.
db_type
(
self
.
connection
)
# Ignore non-concrete fields.
if
field_type
is
None
:
return
errors
if
(
field_type
.
startswith
(
'varchar'
)
and
field
.
unique
and
(
field
.
max_length
is
None
or
int
(
field
.
max_length
)
>
255
)):
errors
.
append
(
checks
.
Error
(
'MySQL does not allow unique CharFields to have a max_length > 255.'
,
obj
=
field
,
id
=
'mysql.E001'
,
)
)
return
errors
tests/invalid_models_tests/test_ordinary_fields.py
Dosyayı görüntüle @
391c450f
...
...
@@ -217,7 +217,7 @@ class CharFieldTests(TestCase):
field
=
models
.
CharField
(
unique
=
True
,
max_length
=
256
)
field
=
Model
.
_meta
.
get_field
(
'field'
)
validator
=
DatabaseValidation
(
connection
=
None
)
validator
=
DatabaseValidation
(
connection
=
connection
)
errors
=
validator
.
check_field
(
field
)
expected
=
[
Error
(
...
...
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