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
a7ad473a
Kaydet (Commit)
a7ad473a
authored
Nis 18, 2016
tarafından
darius BERNARD
Kaydeden (comit)
Tim Graham
May 19, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26515 -- Fixed Query.trim_joins() for nested ForeignObjects.
üst
2e1d44e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
3 deletions
+72
-3
query.py
django/db/models/sql/query.py
+2
-1
__init__.py
tests/foreign_object/models/__init__.py
+4
-2
customers.py
tests/foreign_object/models/customers.py
+38
-0
test_agnostic_order_trimjoin.py
tests/foreign_object/test_agnostic_order_trimjoin.py
+28
-0
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
a7ad473a
...
...
@@ -1438,7 +1438,8 @@ class Query(object):
cur_targets
=
set
(
t
.
column
for
t
in
targets
)
if
not
cur_targets
.
issubset
(
join_targets
):
break
targets
=
tuple
(
r
[
0
]
for
r
in
info
.
join_field
.
related_fields
if
r
[
1
]
.
column
in
cur_targets
)
targets_dict
=
{
r
[
1
]
.
column
:
r
[
0
]
for
r
in
info
.
join_field
.
related_fields
if
r
[
1
]
.
column
in
cur_targets
}
targets
=
tuple
(
targets_dict
[
t
.
column
]
for
t
in
targets
)
self
.
unref_alias
(
joins
.
pop
())
return
targets
,
joins
[
-
1
],
joins
...
...
tests/foreign_object/models/__init__.py
Dosyayı görüntüle @
a7ad473a
from
.article
import
(
Article
,
ArticleIdea
,
ArticleTag
,
ArticleTranslation
,
NewsArticle
,
)
from
.customers
import
Address
,
Contact
,
Customer
from
.empty_join
import
SlugPage
from
.person
import
Country
,
Friendship
,
Group
,
Membership
,
Person
__all__
=
[
'Article'
,
'ArticleIdea'
,
'ArticleTag'
,
'ArticleTranslation'
,
'Country'
,
'Friendship'
,
'Group'
,
'Membership'
,
'NewsArticle'
,
'Person'
,
'SlugPage'
,
'Address'
,
'Article'
,
'ArticleIdea'
,
'ArticleTag'
,
'ArticleTranslation'
,
'Contact'
,
'Country'
,
'Customer'
,
'Friendship'
,
'Group'
,
'Membership'
,
'NewsArticle'
,
'Person'
,
'SlugPage'
,
]
tests/foreign_object/models/customers.py
0 → 100644
Dosyayı görüntüle @
a7ad473a
from
django.db
import
models
from
django.db.models.fields.related
import
ForeignObject
class
Address
(
models
.
Model
):
company
=
models
.
CharField
(
max_length
=
1
)
customer_id
=
models
.
IntegerField
()
class
Meta
:
unique_together
=
[
(
'company'
,
'customer_id'
),
]
class
Customer
(
models
.
Model
):
company
=
models
.
CharField
(
max_length
=
1
)
customer_id
=
models
.
IntegerField
()
address
=
ForeignObject
(
Address
,
models
.
CASCADE
,
null
=
True
,
# order mismatches the Contact ForeignObject.
from_fields
=
[
'company'
,
'customer_id'
],
to_fields
=
[
'company'
,
'customer_id'
],
)
class
Meta
:
unique_together
=
[
(
'company'
,
'customer_id'
),
]
class
Contact
(
models
.
Model
):
company_code
=
models
.
CharField
(
max_length
=
1
)
customer_code
=
models
.
IntegerField
()
customer
=
ForeignObject
(
Customer
,
models
.
CASCADE
,
related_name
=
'contacts'
,
to_fields
=
[
'customer_id'
,
'company'
],
from_fields
=
[
'customer_code'
,
'company_code'
],
)
tests/foreign_object/test_agnostic_order_trimjoin.py
0 → 100644
Dosyayı görüntüle @
a7ad473a
from
operator
import
attrgetter
from
django.test.testcases
import
TestCase
from
.models
import
Address
,
Contact
,
Customer
class
TestLookupQuery
(
TestCase
):
@classmethod
def
setUpTestData
(
cls
):
cls
.
address
=
Address
.
objects
.
create
(
company
=
1
,
customer_id
=
20
)
cls
.
customer1
=
Customer
.
objects
.
create
(
company
=
1
,
customer_id
=
20
)
cls
.
contact1
=
Contact
.
objects
.
create
(
company_code
=
1
,
customer_code
=
20
)
def
test_deep_mixed_forward
(
self
):
self
.
assertQuerysetEqual
(
Address
.
objects
.
filter
(
customer__contacts
=
self
.
contact1
),
[
self
.
address
.
id
],
attrgetter
(
'id'
)
)
def
test_deep_mixed_backward
(
self
):
self
.
assertQuerysetEqual
(
Contact
.
objects
.
filter
(
customer__address
=
self
.
address
),
[
self
.
contact1
.
id
],
attrgetter
(
'id'
)
)
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