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
d2641311
Kaydet (Commit)
d2641311
authored
Şub 10, 2017
tarafından
ClairePhila
Kaydeden (comit)
Tim Graham
Şub 10, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #27148 -- Fixed UUIDField.to_python(None) crash.
Regression in
2f9861d8
.
üst
edad02af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
__init__.py
django/db/models/fields/__init__.py
+1
-3
test_uuid.py
tests/model_fields/test_uuid.py
+12
-1
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
d2641311
...
...
@@ -2337,9 +2337,7 @@ class UUIDField(Field):
return
value
.
hex
def
to_python
(
self
,
value
):
if
value
is
None
:
return
None
if
not
isinstance
(
value
,
uuid
.
UUID
):
if
value
is
not
None
and
not
isinstance
(
value
,
uuid
.
UUID
):
try
:
return
uuid
.
UUID
(
value
)
except
(
AttributeError
,
ValueError
):
...
...
tests/model_fields/test_uuid.py
Dosyayı görüntüle @
d2641311
...
...
@@ -54,13 +54,16 @@ class TestSaveLoad(TestCase):
UUIDModel
.
objects
.
create
(
field
=
'not-a-uuid'
)
class
TestM
igration
s
(
SimpleTestCase
):
class
TestM
ethod
s
(
SimpleTestCase
):
def
test_deconstruct
(
self
):
field
=
models
.
UUIDField
()
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
self
.
assertEqual
(
kwargs
,
{})
def
test_to_python
(
self
):
self
.
assertIsNone
(
models
.
UUIDField
()
.
to_python
(
None
))
class
TestQuerying
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -88,6 +91,10 @@ class TestSerialization(SimpleTestCase):
'[{"fields": {"field": "550e8400-e29b-41d4-a716-446655440000"}, '
'"model": "model_fields.uuidmodel", "pk": null}]'
)
nullable_test_data
=
(
'[{"fields": {"field": null}, '
'"model": "model_fields.nullableuuidmodel", "pk": null}]'
)
def
test_dumping
(
self
):
instance
=
UUIDModel
(
field
=
uuid
.
UUID
(
'550e8400e29b41d4a716446655440000'
))
...
...
@@ -98,6 +105,10 @@ class TestSerialization(SimpleTestCase):
instance
=
list
(
serializers
.
deserialize
(
'json'
,
self
.
test_data
))[
0
]
.
object
self
.
assertEqual
(
instance
.
field
,
uuid
.
UUID
(
'550e8400-e29b-41d4-a716-446655440000'
))
def
test_nullable_loading
(
self
):
instance
=
list
(
serializers
.
deserialize
(
'json'
,
self
.
nullable_test_data
))[
0
]
.
object
self
.
assertIsNone
(
instance
.
field
)
class
TestValidation
(
SimpleTestCase
):
def
test_invalid_uuid
(
self
):
...
...
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