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
ec50937b
Kaydet (Commit)
ec50937b
authored
Nis 23, 2017
tarafından
Simon Charette
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #20939 -- Removed the Query._forced_pk hack.
üst
fcb5dbfe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
related_lookups.py
django/db/models/fields/related_lookups.py
+1
-1
lookups.py
django/db/models/lookups.py
+3
-0
query.py
django/db/models/query.py
+2
-5
query.py
django/db/models/sql/query.py
+5
-5
No files found.
django/db/models/fields/related_lookups.py
Dosyayı görüntüle @
ec50937b
...
@@ -81,7 +81,7 @@ class RelatedIn(In):
...
@@ -81,7 +81,7 @@ class RelatedIn(In):
AND
)
AND
)
return
root_constraint
.
as_sql
(
compiler
,
connection
)
return
root_constraint
.
as_sql
(
compiler
,
connection
)
else
:
else
:
if
getattr
(
self
.
rhs
,
'_forced_pk'
,
Fals
e
):
if
not
getattr
(
self
.
rhs
,
'has_select_fields'
,
Tru
e
):
self
.
rhs
.
clear_select_clause
()
self
.
rhs
.
clear_select_clause
()
if
(
getattr
(
self
.
lhs
.
output_field
,
'primary_key'
,
False
)
and
if
(
getattr
(
self
.
lhs
.
output_field
,
'primary_key'
,
False
)
and
self
.
lhs
.
output_field
.
model
==
self
.
rhs
.
model
):
self
.
lhs
.
output_field
.
model
==
self
.
rhs
.
model
):
...
...
django/db/models/lookups.py
Dosyayı görüntüle @
ec50937b
...
@@ -367,6 +367,9 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
...
@@ -367,6 +367,9 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
placeholder
=
'('
+
', '
.
join
(
sqls
)
+
')'
placeholder
=
'('
+
', '
.
join
(
sqls
)
+
')'
return
(
placeholder
,
sqls_params
)
return
(
placeholder
,
sqls_params
)
else
:
else
:
if
not
getattr
(
self
.
rhs
,
'has_select_fields'
,
True
):
self
.
rhs
.
clear_select_clause
()
self
.
rhs
.
add_fields
([
'pk'
])
return
super
()
.
process_rhs
(
compiler
,
connection
)
return
super
()
.
process_rhs
(
compiler
,
connection
)
def
get_rhs_op
(
self
,
connection
,
rhs
):
def
get_rhs_op
(
self
,
connection
,
rhs
):
...
...
django/db/models/query.py
Dosyayı görüntüle @
ec50937b
...
@@ -1100,15 +1100,12 @@ class QuerySet:
...
@@ -1100,15 +1100,12 @@ class QuerySet:
self
.
_known_related_objects
.
setdefault
(
field
,
{})
.
update
(
objects
)
self
.
_known_related_objects
.
setdefault
(
field
,
{})
.
update
(
objects
)
def
_prepare_as_filter_value
(
self
):
def
_prepare_as_filter_value
(
self
):
if
self
.
_fields
is
None
:
if
self
.
_fields
and
len
(
self
.
_fields
)
>
1
:
queryset
=
self
.
values
(
'pk'
)
queryset
.
query
.
_forced_pk
=
True
else
:
# values() queryset can only be used as nested queries
# values() queryset can only be used as nested queries
# if they are set up to select only a single field.
# if they are set up to select only a single field.
if
len
(
self
.
_fields
)
>
1
:
if
len
(
self
.
_fields
)
>
1
:
raise
TypeError
(
'Cannot use multi-field values as a filter value.'
)
raise
TypeError
(
'Cannot use multi-field values as a filter value.'
)
queryset
=
self
.
_clone
()
queryset
=
self
.
_clone
()
return
queryset
.
query
.
as_subquery_filter
(
queryset
.
_db
)
return
queryset
.
query
.
as_subquery_filter
(
queryset
.
_db
)
def
_add_hints
(
self
,
**
hints
):
def
_add_hints
(
self
,
**
hints
):
...
...
django/db/models/sql/query.py
Dosyayı görüntüle @
ec50937b
...
@@ -214,6 +214,10 @@ class Query:
...
@@ -214,6 +214,10 @@ class Query:
self
.
_annotations
=
OrderedDict
()
self
.
_annotations
=
OrderedDict
()
return
self
.
_annotations
return
self
.
_annotations
@property
def
has_select_fields
(
self
):
return
bool
(
self
.
select
or
self
.
annotation_select_mask
or
self
.
extra_select_mask
)
def
__str__
(
self
):
def
__str__
(
self
):
"""
"""
Return the query as a string of SQL with the parameter values
Return the query as a string of SQL with the parameter values
...
@@ -326,7 +330,6 @@ class Query:
...
@@ -326,7 +330,6 @@ class Query:
if
hasattr
(
obj
,
'_setup_query'
):
if
hasattr
(
obj
,
'_setup_query'
):
obj
.
_setup_query
()
obj
.
_setup_query
()
obj
.
context
=
self
.
context
.
copy
()
obj
.
context
=
self
.
context
.
copy
()
obj
.
_forced_pk
=
getattr
(
self
,
'_forced_pk'
,
False
)
return
obj
return
obj
def
add_context
(
self
,
key
,
value
):
def
add_context
(
self
,
key
,
value
):
...
@@ -1060,10 +1063,7 @@ class Query:
...
@@ -1060,10 +1063,7 @@ class Query:
# opts would be Author's (from the author field) and value.model
# opts would be Author's (from the author field) and value.model
# would be Author.objects.all() queryset's .model (Author also).
# would be Author.objects.all() queryset's .model (Author also).
# The field is the related field on the lhs side.
# The field is the related field on the lhs side.
# If _forced_pk isn't set, this isn't a queryset query or values()
if
(
isinstance
(
value
,
Query
)
and
not
value
.
has_select_fields
and
# or values_list() was specified by the developer in which case
# that choice is trusted.
if
(
getattr
(
value
,
'_forced_pk'
,
False
)
and
not
check_rel_lookup_compatibility
(
value
.
model
,
opts
,
field
)):
not
check_rel_lookup_compatibility
(
value
.
model
,
opts
,
field
)):
raise
ValueError
(
raise
ValueError
(
'Cannot use QuerySet for "
%
s": Use a QuerySet for "
%
s".'
%
'Cannot use QuerySet for "
%
s": Use a QuerySet for "
%
s".'
%
...
...
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