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
3a505c70
Kaydet (Commit)
3a505c70
authored
Mar 06, 2019
tarafından
Simon Charette
Kaydeden (comit)
Tim Graham
Mar 22, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #27149, #29542 -- Simplified subquery parentheses wrapping logic.
üst
35431298
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
21 deletions
+8
-21
expressions.py
django/db/models/expressions.py
+2
-12
lookups.py
django/db/models/lookups.py
+1
-2
compiler.py
django/db/models/sql/compiler.py
+1
-6
query.py
django/db/models/sql/query.py
+4
-1
No files found.
django/db/models/expressions.py
Dosyayı görüntüle @
3a505c70
...
...
@@ -1023,23 +1023,13 @@ class Subquery(Expression):
def
as_sql
(
self
,
compiler
,
connection
,
template
=
None
,
**
extra_context
):
connection
.
ops
.
check_expression_support
(
self
)
template_params
=
{
**
self
.
extra
,
**
extra_context
}
template_params
[
'subquery'
],
sql_params
=
self
.
query
.
as_sql
(
compiler
,
connection
)
subquery_sql
,
sql_params
=
self
.
query
.
as_sql
(
compiler
,
connection
)
template_params
[
'subquery'
]
=
subquery_sql
[
1
:
-
1
]
template
=
template
or
template_params
.
get
(
'template'
,
self
.
template
)
sql
=
template
%
template_params
return
sql
,
sql_params
def
_prepare
(
self
,
output_field
):
# This method will only be called if this instance is the "rhs" in an
# expression: the wrapping () must be removed (as the expression that
# contains this will provide them). SQLite evaluates ((subquery))
# differently than the other databases.
if
self
.
template
==
'(
%(subquery)
s)'
:
clone
=
self
.
copy
()
clone
.
template
=
'
%(subquery)
s'
return
clone
return
self
def
get_group_by_cols
(
self
,
alias
=
None
):
if
alias
:
return
[
Ref
(
alias
,
self
)]
...
...
django/db/models/lookups.py
Dosyayı görüntüle @
3a505c70
...
...
@@ -89,8 +89,7 @@ class Lookup:
value
=
self
.
apply_bilateral_transforms
(
value
)
value
=
value
.
resolve_expression
(
compiler
.
query
)
if
hasattr
(
value
,
'as_sql'
):
sql
,
params
=
compiler
.
compile
(
value
)
return
'('
+
sql
+
')'
,
params
return
compiler
.
compile
(
value
)
else
:
return
self
.
get_db_prep_lookup
(
value
,
connection
)
...
...
django/db/models/sql/compiler.py
Dosyayı görüntüle @
3a505c70
...
...
@@ -5,7 +5,7 @@ from itertools import chain
from
django.core.exceptions
import
EmptyResultSet
,
FieldError
from
django.db.models.constants
import
LOOKUP_SEP
from
django.db.models.expressions
import
OrderBy
,
Random
,
RawSQL
,
Ref
,
Subquery
from
django.db.models.expressions
import
OrderBy
,
Random
,
RawSQL
,
Ref
from
django.db.models.query_utils
import
QueryWrapper
,
select_related_descend
from
django.db.models.sql.constants
import
(
CURSOR
,
GET_ITERATOR_CHUNK_SIZE
,
MULTI
,
NO_RESULTS
,
ORDER_DIR
,
SINGLE
,
...
...
@@ -126,11 +126,6 @@ class SQLCompiler:
for
expr
in
expressions
:
sql
,
params
=
self
.
compile
(
expr
)
if
isinstance
(
expr
,
Subquery
)
and
not
sql
.
startswith
(
'('
):
# Subquery expression from HAVING clause may not contain
# wrapping () because they could be removed when a subquery is
# the "rhs" in an expression (see Subquery._prepare()).
sql
=
'(
%
s)'
%
sql
if
(
sql
,
tuple
(
params
))
not
in
seen
:
result
.
append
((
sql
,
params
))
seen
.
add
((
sql
,
tuple
(
params
)))
...
...
django/db/models/sql/query.py
Dosyayı görüntüle @
3a505c70
...
...
@@ -1022,7 +1022,10 @@ class Query(BaseExpression):
return
clone
def
as_sql
(
self
,
compiler
,
connection
):
return
self
.
get_compiler
(
connection
=
connection
)
.
as_sql
()
sql
,
params
=
self
.
get_compiler
(
connection
=
connection
)
.
as_sql
()
if
self
.
subquery
:
sql
=
'(
%
s)'
%
sql
return
sql
,
params
def
resolve_lookup_value
(
self
,
value
,
can_reuse
,
allow_joins
,
simple_col
):
if
hasattr
(
value
,
'resolve_expression'
):
...
...
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