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
e7abb5ba
Kaydet (Commit)
e7abb5ba
authored
Eyl 09, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27204 -- Made clashing m2m intermediary table checks ignore unmanaged models.
üst
652bcc6f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
related.py
django/db/models/fields/related.py
+2
-2
test_models.py
tests/invalid_models_tests/test_models.py
+30
-0
No files found.
django/db/models/fields/related.py
Dosyayı görüntüle @
e7abb5ba
...
...
@@ -1438,12 +1438,12 @@ class ManyToManyField(RelatedField):
return
errors
def
_check_table_uniqueness
(
self
,
**
kwargs
):
if
isinstance
(
self
.
remote_field
.
through
,
six
.
string_types
):
if
isinstance
(
self
.
remote_field
.
through
,
six
.
string_types
)
or
not
self
.
remote_field
.
through
.
_meta
.
managed
:
return
[]
registered_tables
=
{
model
.
_meta
.
db_table
:
model
for
model
in
self
.
opts
.
apps
.
get_models
(
include_auto_created
=
True
)
if
model
!=
self
.
remote_field
.
through
if
model
!=
self
.
remote_field
.
through
and
model
.
_meta
.
managed
}
m2m_db_table
=
self
.
m2m_db_table
()
if
m2m_db_table
in
registered_tables
:
...
...
tests/invalid_models_tests/test_models.py
Dosyayı görüntüle @
e7abb5ba
...
...
@@ -830,6 +830,36 @@ class OtherModelTests(SimpleTestCase):
)
])
def
test_m2m_unmanaged_shadow_models_not_checked
(
self
):
class
A1
(
models
.
Model
):
pass
class
C1
(
models
.
Model
):
mm_a
=
models
.
ManyToManyField
(
A1
,
db_table
=
'd1'
)
# Unmanaged models that shadow the above models. Reused table names
# shouldn't be flagged by any checks.
class
A2
(
models
.
Model
):
class
Meta
:
managed
=
False
class
C2
(
models
.
Model
):
mm_a
=
models
.
ManyToManyField
(
A2
,
through
=
'Intermediate'
)
class
Meta
:
managed
=
False
class
Intermediate
(
models
.
Model
):
a2
=
models
.
ForeignKey
(
A2
,
models
.
CASCADE
,
db_column
=
'a1_id'
)
c2
=
models
.
ForeignKey
(
C2
,
models
.
CASCADE
,
db_column
=
'c1_id'
)
class
Meta
:
db_table
=
'd1'
managed
=
False
self
.
assertEqual
(
C1
.
check
(),
[])
self
.
assertEqual
(
C2
.
check
(),
[])
@isolate_apps
(
'django.contrib.auth'
,
kwarg_name
=
'apps'
)
def
test_lazy_reference_checks
(
self
,
apps
):
class
DummyModel
(
models
.
Model
):
...
...
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