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
9385aa31
Kaydet (Commit)
9385aa31
authored
Şub 15, 2014
tarafından
Lovas Bence
Kaydeden (comit)
Tim Graham
Haz 25, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22050 -- Fixed defer fields on proxy related models.
üst
815e7a57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
query.py
django/db/models/sql/query.py
+1
-1
models.py
tests/defer_regress/models.py
+5
-0
tests.py
tests/defer_regress/tests.py
+14
-1
No files found.
django/db/models/sql/query.py
Dosyayı görüntüle @
9385aa31
...
@@ -585,7 +585,7 @@ class Query(object):
...
@@ -585,7 +585,7 @@ class Query(object):
must_include
=
{
orig_opts
.
concrete_model
:
set
([
orig_opts
.
pk
])}
must_include
=
{
orig_opts
.
concrete_model
:
set
([
orig_opts
.
pk
])}
for
field_name
in
field_names
:
for
field_name
in
field_names
:
parts
=
field_name
.
split
(
LOOKUP_SEP
)
parts
=
field_name
.
split
(
LOOKUP_SEP
)
cur_model
=
self
.
model
cur_model
=
self
.
model
.
_meta
.
concrete_model
opts
=
orig_opts
opts
=
orig_opts
for
name
in
parts
[:
-
1
]:
for
name
in
parts
[:
-
1
]:
old_model
=
cur_model
old_model
=
cur_model
...
...
tests/defer_regress/models.py
Dosyayı görüntüle @
9385aa31
...
@@ -21,6 +21,11 @@ class RelatedItem(models.Model):
...
@@ -21,6 +21,11 @@ class RelatedItem(models.Model):
item
=
models
.
ForeignKey
(
Item
)
item
=
models
.
ForeignKey
(
Item
)
class
ProxyRelated
(
RelatedItem
):
class
Meta
:
proxy
=
True
class
Child
(
models
.
Model
):
class
Child
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
10
)
name
=
models
.
CharField
(
max_length
=
10
)
value
=
models
.
IntegerField
()
value
=
models
.
IntegerField
()
...
...
tests/defer_regress/tests.py
Dosyayı görüntüle @
9385aa31
...
@@ -10,7 +10,9 @@ from django.test import TestCase, override_settings
...
@@ -10,7 +10,9 @@ from django.test import TestCase, override_settings
from
.models
import
(
from
.models
import
(
ResolveThis
,
Item
,
RelatedItem
,
Child
,
Leaf
,
Proxy
,
SimpleItem
,
Feature
,
ResolveThis
,
Item
,
RelatedItem
,
Child
,
Leaf
,
Proxy
,
SimpleItem
,
Feature
,
ItemAndSimpleItem
,
OneToOneItem
,
SpecialFeature
,
Location
,
Request
)
ItemAndSimpleItem
,
OneToOneItem
,
SpecialFeature
,
Location
,
Request
,
ProxyRelated
,
)
class
DeferRegressionTest
(
TestCase
):
class
DeferRegressionTest
(
TestCase
):
...
@@ -207,6 +209,17 @@ class DeferRegressionTest(TestCase):
...
@@ -207,6 +209,17 @@ class DeferRegressionTest(TestCase):
self
.
assertEqual
(
obj
.
item
,
item2
)
self
.
assertEqual
(
obj
.
item
,
item2
)
self
.
assertEqual
(
obj
.
item_id
,
item2
.
id
)
self
.
assertEqual
(
obj
.
item_id
,
item2
.
id
)
def
test_proxy_model_defer_with_selected_related
(
self
):
# Regression for #22050
item
=
Item
.
objects
.
create
(
name
=
"first"
,
value
=
47
)
related
=
RelatedItem
.
objects
.
create
(
item
=
item
)
# Defer fields with only()
obj
=
ProxyRelated
.
objects
.
all
()
.
select_related
()
.
only
(
'item__name'
)[
0
]
with
self
.
assertNumQueries
(
0
):
self
.
assertEqual
(
obj
.
item
.
name
,
"first"
)
with
self
.
assertNumQueries
(
1
):
self
.
assertEqual
(
obj
.
item
.
value
,
47
)
def
test_only_with_select_related
(
self
):
def
test_only_with_select_related
(
self
):
# Test for #17485.
# Test for #17485.
item
=
SimpleItem
.
objects
.
create
(
name
=
'first'
,
value
=
47
)
item
=
SimpleItem
.
objects
.
create
(
name
=
'first'
,
value
=
47
)
...
...
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