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
8e8c0792
Kaydet (Commit)
8e8c0792
authored
Agu 08, 2015
tarafından
Simon Charette
Kaydeden (comit)
Tim Graham
Eyl 23, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #18081 -- Asserted db constraints are created for fk to proxy models.
üst
de314231
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
tests.py
tests/schema/tests.py
+30
-0
No files found.
tests/schema/tests.py
Dosyayı görüntüle @
8e8c0792
...
@@ -177,6 +177,36 @@ class SchemaTests(TransactionTestCase):
...
@@ -177,6 +177,36 @@ class SchemaTests(TransactionTestCase):
else
:
else
:
self
.
fail
(
"No FK constraint for author_id found"
)
self
.
fail
(
"No FK constraint for author_id found"
)
@skipUnlessDBFeature
(
'supports_foreign_keys'
)
def
test_fk_to_proxy
(
self
):
"Tests that creating a FK to a proxy model creates database constraints."
class
AuthorProxy
(
Author
):
class
Meta
:
app_label
=
'schema'
apps
=
new_apps
proxy
=
True
class
AuthorRef
(
Model
):
author
=
ForeignKey
(
AuthorProxy
,
on_delete
=
CASCADE
)
class
Meta
:
app_label
=
'schema'
apps
=
new_apps
self
.
local_models
=
[
AuthorProxy
,
AuthorRef
]
# Create the table
with
connection
.
schema_editor
()
as
editor
:
editor
.
create_model
(
Author
)
editor
.
create_model
(
AuthorRef
)
constraints
=
self
.
get_constraints
(
AuthorRef
.
_meta
.
db_table
)
for
details
in
constraints
.
values
():
if
details
[
'columns'
]
==
[
'author_id'
]
and
details
[
'foreign_key'
]:
self
.
assertEqual
(
details
[
'foreign_key'
],
(
'schema_author'
,
'id'
))
break
else
:
self
.
fail
(
'No FK constraint for author_id found'
)
@skipUnlessDBFeature
(
'supports_foreign_keys'
)
@skipUnlessDBFeature
(
'supports_foreign_keys'
)
def
test_fk_db_constraint
(
self
):
def
test_fk_db_constraint
(
self
):
"Tests that the db_constraint parameter is respected"
"Tests that the db_constraint parameter is respected"
...
...
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