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
ad994a3c
Kaydet (Commit)
ad994a3c
authored
May 22, 2014
tarafından
Moayad Mardini
Kaydeden (comit)
Baptiste Mispelon
May 22, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.
Thanks rockallite.wulf for the report.
üst
635acf42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
writer.py
django/db/migrations/writer.py
+6
-2
test_writer.py
tests/migrations/test_writer.py
+12
-0
No files found.
django/db/migrations/writer.py
Dosyayı görüntüle @
ad994a3c
...
...
@@ -206,7 +206,9 @@ class MigrationWriter(object):
if
isinstance
(
value
,
set
):
format
=
"set([
%
s])"
elif
isinstance
(
value
,
tuple
):
format
=
"(
%
s)"
if
len
(
value
)
>
1
else
"(
%
s,)"
# When len(value)==0, the empty tuple should be serialized as
# "()", not "(,)" because (,) is invalid Python syntax.
format
=
"(
%
s)"
if
len
(
value
)
!=
1
else
"(
%
s,)"
else
:
format
=
"[
%
s]"
return
format
%
(
", "
.
join
(
strings
)),
imports
...
...
@@ -296,7 +298,9 @@ class MigrationWriter(object):
item_string
,
item_imports
=
cls
.
serialize
(
item
)
imports
.
update
(
item_imports
)
strings
.
append
(
item_string
)
format
=
"(
%
s)"
if
len
(
strings
)
>
1
else
"(
%
s,)"
# When len(strings)==0, the empty iterable should be serialized as
# "()", not "(,)" because (,) is invalid Python syntax.
format
=
"(
%
s)"
if
len
(
strings
)
!=
1
else
"(
%
s,)"
return
format
%
(
", "
.
join
(
strings
)),
imports
# Uh oh.
else
:
...
...
tests/migrations/test_writer.py
Dosyayı görüntüle @
ad994a3c
...
...
@@ -125,6 +125,18 @@ class WriterTests(TestCase):
)
)
def
test_serialize_empty_nonempty_tuple
(
self
):
"""
Ticket #22679: makemigrations generates invalid code for (an empty
tuple) default_permissions = ()
"""
empty_tuple
=
()
one_item_tuple
=
(
'a'
)
many_items_tuple
=
(
'a'
,
'b'
,
'c'
)
self
.
assertSerializedEqual
(
empty_tuple
)
self
.
assertSerializedEqual
(
one_item_tuple
)
self
.
assertSerializedEqual
(
many_items_tuple
)
def
test_simple_migration
(
self
):
"""
Tests serializing a simple migration.
...
...
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