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
f9a33e3c
Kaydet (Commit)
f9a33e3c
authored
Ara 02, 2018
tarafından
Mariusz Felisiak
Kaydeden (comit)
Tim Graham
Ara 06, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29932 -- Fixed combining compound queries with sub-compound queries on SQLite and Oracle.
üst
ae180fa4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
1 deletion
+19
-1
features.py
django/db/backends/base/features.py
+1
-0
features.py
django/db/backends/sqlite3/features.py
+1
-0
compiler.py
django/db/models/sql/compiler.py
+11
-1
test_qs_combinators.py
tests/queries/test_qs_combinators.py
+6
-0
No files found.
django/db/backends/base/features.py
Dosyayı görüntüle @
f9a33e3c
...
...
@@ -226,6 +226,7 @@ class BaseDatabaseFeatures:
supports_select_intersection
=
True
supports_select_difference
=
True
supports_slicing_ordering_in_compound
=
False
supports_parentheses_in_compound
=
True
# Does the database support SQL 2003 FILTER (WHERE ...) in aggregate
# expressions?
...
...
django/db/backends/sqlite3/features.py
Dosyayı görüntüle @
f9a33e3c
...
...
@@ -37,6 +37,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_partial_indexes
=
Database
.
version_info
>=
(
3
,
8
,
0
)
# Is "ALTER TABLE ... RENAME COLUMN" supported?
can_alter_table_rename_column
=
Database
.
sqlite_version_info
>=
(
3
,
25
,
0
)
supports_parentheses_in_compound
=
False
@cached_property
def
supports_stddev
(
self
):
...
...
django/db/models/sql/compiler.py
Dosyayı görüntüle @
f9a33e3c
...
...
@@ -429,7 +429,17 @@ class SQLCompiler:
*
self
.
query
.
values_select
,
*
self
.
query
.
annotation_select
,
))
parts
+=
(
compiler
.
as_sql
(),)
part_sql
,
part_args
=
compiler
.
as_sql
()
if
compiler
.
query
.
combinator
:
# Wrap in a subquery if wrapping in parentheses isn't
# supported.
if
not
features
.
supports_parentheses_in_compound
:
part_sql
=
'SELECT * FROM ({})'
.
format
(
part_sql
)
# Add parentheses when combining with compound query if not
# already added for all compound queries.
elif
not
features
.
supports_slicing_ordering_in_compound
:
part_sql
=
'({})'
.
format
(
part_sql
)
parts
+=
((
part_sql
,
part_args
),)
except
EmptyResultSet
:
# Omit the empty queryset with UNION and with DIFFERENCE if the
# first queryset is nonempty.
...
...
tests/queries/test_qs_combinators.py
Dosyayı görüntüle @
f9a33e3c
...
...
@@ -214,3 +214,9 @@ class QuerySetSetOperationTests(TestCase):
list
(
qs1
.
union
(
qs2
)
.
order_by
(
'num'
))
# switched order, now 'exists' again:
list
(
qs2
.
union
(
qs1
)
.
order_by
(
'num'
))
@skipUnlessDBFeature
(
'supports_select_difference'
,
'supports_select_intersection'
)
def
test_qs_with_subcompound_qs
(
self
):
qs1
=
Number
.
objects
.
all
()
qs2
=
Number
.
objects
.
intersection
(
Number
.
objects
.
filter
(
num__gt
=
1
))
self
.
assertEqual
(
qs1
.
difference
(
qs2
)
.
count
(),
2
)
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