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
567b9928
Kaydet (Commit)
567b9928
authored
May 02, 2019
tarafından
can
Kaydeden (comit)
Mariusz Felisiak
May 03, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29692 -- Fixed removing ordering parts for multiline RawSQL expressions.
üst
ef082ebb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
compiler.py
django/db/models/sql/compiler.py
+2
-1
tests.py
tests/expressions/tests.py
+23
-0
No files found.
django/db/models/sql/compiler.py
Dosyayı görüntüle @
567b9928
...
@@ -32,7 +32,8 @@ class SQLCompiler:
...
@@ -32,7 +32,8 @@ class SQLCompiler:
self
.
select
=
None
self
.
select
=
None
self
.
annotation_col_map
=
None
self
.
annotation_col_map
=
None
self
.
klass_info
=
None
self
.
klass_info
=
None
self
.
ordering_parts
=
re
.
compile
(
r'(.*)\s(ASC|DESC)(.*)'
)
# Multiline ordering SQL clause may appear from RawSQL.
self
.
ordering_parts
=
re
.
compile
(
r'^(.*)\s(ASC|DESC)(.*)'
,
re
.
MULTILINE
|
re
.
DOTALL
)
self
.
_meta_ordering
=
None
self
.
_meta_ordering
=
None
def
setup_query
(
self
):
def
setup_query
(
self
):
...
...
tests/expressions/tests.py
Dosyayı görüntüle @
567b9928
...
@@ -384,6 +384,29 @@ class BasicExpressionsTests(TestCase):
...
@@ -384,6 +384,29 @@ class BasicExpressionsTests(TestCase):
)
)
self
.
assertSequenceEqual
(
mustermanns_by_seniority
,
[
self
.
max
,
mary
])
self
.
assertSequenceEqual
(
mustermanns_by_seniority
,
[
self
.
max
,
mary
])
def
test_order_by_multiline_sql
(
self
):
raw_order_by
=
(
RawSQL
(
'''
CASE WHEN num_employees > 1000
THEN num_chairs
ELSE 0 END
'''
,
[])
.
desc
(),
RawSQL
(
'''
CASE WHEN num_chairs > 1
THEN 1
ELSE 0 END
'''
,
[])
.
asc
()
)
for
qs
in
(
Company
.
objects
.
all
(),
Company
.
objects
.
distinct
(),
):
with
self
.
subTest
(
qs
=
qs
):
self
.
assertSequenceEqual
(
qs
.
order_by
(
*
raw_order_by
),
[
self
.
example_inc
,
self
.
gmbh
,
self
.
foobar_ltd
],
)
def
test_outerref
(
self
):
def
test_outerref
(
self
):
inner
=
Company
.
objects
.
filter
(
point_of_contact
=
OuterRef
(
'pk'
))
inner
=
Company
.
objects
.
filter
(
point_of_contact
=
OuterRef
(
'pk'
))
msg
=
(
msg
=
(
...
...
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