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
c9159a08
Kaydet (Commit)
c9159a08
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._prepare_as_filter_value() hack.
üst
ec50937b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
22 deletions
+17
-22
query.py
django/db/models/query.py
+5
-3
query.py
django/db/models/sql/query.py
+12
-19
No files found.
django/db/models/query.py
Dosyayı görüntüle @
c9159a08
...
...
@@ -1099,14 +1099,16 @@ class QuerySet:
for
field
,
objects
in
other
.
_known_related_objects
.
items
():
self
.
_known_related_objects
.
setdefault
(
field
,
{})
.
update
(
objects
)
def
_prepare_as_filter_value
(
self
):
def
resolve_expression
(
self
,
*
args
,
**
kwargs
):
if
self
.
_fields
and
len
(
self
.
_fields
)
>
1
:
# values() queryset can only be used as nested queries
# if they are set up to select only a single field.
if
len
(
self
.
_fields
)
>
1
:
raise
TypeError
(
'Cannot use multi-field values as a filter value.'
)
queryset
=
self
.
_clone
()
return
queryset
.
query
.
as_subquery_filter
(
queryset
.
_db
)
query
=
self
.
query
.
resolve_expression
(
*
args
,
**
kwargs
)
query
.
_db
=
self
.
_db
return
query
resolve_expression
.
queryset_only
=
True
def
_add_hints
(
self
,
**
hints
):
"""
...
...
django/db/models/sql/query.py
Dosyayı görüntüle @
c9159a08
...
...
@@ -976,8 +976,18 @@ class Query:
self
.
append_annotation_mask
([
alias
])
self
.
annotations
[
alias
]
=
annotation
def
_prepare_as_filter_value
(
self
):
return
self
.
clone
()
def
resolve_expression
(
self
,
query
,
*
args
,
**
kwargs
):
clone
=
self
.
clone
()
# Subqueries need to use a different set of aliases than the outer query.
clone
.
bump_prefix
(
query
)
clone
.
subquery
=
True
# It's safe to drop ordering if the queryset isn't using slicing,
# distinct(*fields) or select_for_update().
if
(
self
.
low_mark
==
0
and
self
.
high_mark
is
None
and
not
self
.
distinct_fields
and
not
self
.
select_for_update
):
clone
.
clear_ordering
(
True
)
return
clone
def
prepare_lookup_value
(
self
,
value
,
lookups
,
can_reuse
,
allow_joins
=
True
):
# Default lookup if none given is exact.
...
...
@@ -1008,12 +1018,6 @@ class Query:
# The used_joins for a tuple of expressions is the union of
# the used_joins for the individual expressions.
used_joins
|=
set
(
k
for
k
,
v
in
self
.
alias_refcount
.
items
()
if
v
>
pre_joins
.
get
(
k
,
0
))
# Subqueries need to use a different set of aliases than the
# outer query. Call bump_prefix to change aliases of the inner
# query (the value).
if
hasattr
(
value
,
'_prepare_as_filter_value'
):
value
=
value
.
_prepare_as_filter_value
()
value
.
bump_prefix
(
self
)
# For Oracle '' is equivalent to null. The check needs to be done
# at this stage because join promotion can't be done at compiler
# stage. Using DEFAULT_DB_ALIAS isn't nice, but it is the best we
...
...
@@ -1981,17 +1985,6 @@ class Query:
else
:
return
field
.
null
def
as_subquery_filter
(
self
,
db
):
self
.
_db
=
db
self
.
subquery
=
True
# It's safe to drop ordering if the queryset isn't using slicing,
# distinct(*fields) or select_for_update().
if
(
self
.
low_mark
==
0
and
self
.
high_mark
is
None
and
not
self
.
distinct_fields
and
not
self
.
select_for_update
):
self
.
clear_ordering
(
True
)
return
self
def
get_order_dir
(
field
,
default
=
'ASC'
):
"""
...
...
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