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
6485a5f4
Kaydet (Commit)
6485a5f4
authored
Nis 30, 2019
tarafından
zeyneloz
Kaydeden (comit)
Mariusz Felisiak
May 01, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30409 -- Allowed using foreign key's attnames in unique/index_together and Index's fields.
üst
2106b983
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
3 deletions
+45
-3
AUTHORS
AUTHORS
+1
-0
base.py
django/db/models/base.py
+5
-3
test_models.py
tests/invalid_models_tests/test_models.py
+39
-0
No files found.
AUTHORS
Dosyayı görüntüle @
6485a5f4
...
...
@@ -918,6 +918,7 @@ answer newbie questions, and generally made Django that much better:
Žan Anderle <zan.anderle@gmail.com>
Zbigniew Siciarz <zbigniew@siciarz.net>
zegor
Zeynel Özdemir <ozdemir.zynl@gmail.com>
Zlatko Mašek <zlatko.masek@gmail.com>
<Please alphabetize new entries>
...
...
django/db/models/base.py
Dosyayı görüntüle @
6485a5f4
...
...
@@ -1571,9 +1571,11 @@ class Model(metaclass=ModelBase):
# In order to avoid hitting the relation tree prematurely, we use our
# own fields_map instead of using get_field()
forward_fields_map
=
{
field
.
name
:
field
for
field
in
cls
.
_meta
.
_get_fields
(
reverse
=
False
)
}
forward_fields_map
=
{}
for
field
in
cls
.
_meta
.
_get_fields
(
reverse
=
False
):
forward_fields_map
[
field
.
name
]
=
field
if
hasattr
(
field
,
'attname'
):
forward_fields_map
[
field
.
attname
]
=
field
errors
=
[]
for
field_name
in
fields
:
...
...
tests/invalid_models_tests/test_models.py
Dosyayı görüntüle @
6485a5f4
...
...
@@ -117,6 +117,19 @@ class IndexTogetherTests(SimpleTestCase):
),
])
def
test_pointing_to_fk
(
self
):
class
Foo
(
models
.
Model
):
pass
class
Bar
(
models
.
Model
):
foo_1
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_1'
)
foo_2
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_2'
)
class
Meta
:
index_together
=
[[
'foo_1_id'
,
'foo_2'
]]
self
.
assertEqual
(
Bar
.
check
(),
[])
# unique_together tests are very similar to index_together tests.
@isolate_apps
(
'invalid_models_tests'
)
...
...
@@ -204,6 +217,19 @@ class UniqueTogetherTests(SimpleTestCase):
),
])
def
test_pointing_to_fk
(
self
):
class
Foo
(
models
.
Model
):
pass
class
Bar
(
models
.
Model
):
foo_1
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_1'
)
foo_2
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_2'
)
class
Meta
:
unique_together
=
[[
'foo_1_id'
,
'foo_2'
]]
self
.
assertEqual
(
Bar
.
check
(),
[])
@isolate_apps
(
'invalid_models_tests'
)
class
IndexesTests
(
SimpleTestCase
):
...
...
@@ -257,6 +283,19 @@ class IndexesTests(SimpleTestCase):
),
])
def
test_pointing_to_fk
(
self
):
class
Foo
(
models
.
Model
):
pass
class
Bar
(
models
.
Model
):
foo_1
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_1'
)
foo_2
=
models
.
ForeignKey
(
Foo
,
on_delete
=
models
.
CASCADE
,
related_name
=
'bar_2'
)
class
Meta
:
indexes
=
[
models
.
Index
(
fields
=
[
'foo_1_id'
,
'foo_2'
],
name
=
'index_name'
)]
self
.
assertEqual
(
Bar
.
check
(),
[])
@isolate_apps
(
'invalid_models_tests'
)
class
FieldNamesTests
(
SimpleTestCase
):
...
...
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