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
feb683c4
Unverified
Kaydet (Commit)
feb683c4
authored
Mar 14, 2018
tarafından
Mariusz Felisiak
Kaydeden (comit)
GitHub
Mar 14, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29155 -- Fixed crash when database functions are used with pattern lookups.
Thanks Tim Graham and Sergey Fedoseev for reviews.
üst
8f75984c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
lookups.py
django/db/models/lookups.py
+1
-1
models.py
tests/lookup/models.py
+1
-0
tests.py
tests/lookup/tests.py
+17
-0
No files found.
django/db/models/lookups.py
Dosyayı görüntüle @
feb683c4
...
...
@@ -397,7 +397,7 @@ class PatternLookup(BuiltinLookup):
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
if
self
.
rhs_is_direct_value
()
and
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
self
.
param_pattern
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
...
...
tests/lookup/models.py
Dosyayı görüntüle @
feb683c4
...
...
@@ -17,6 +17,7 @@ class Alarm(models.Model):
class
Author
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
alias
=
models
.
CharField
(
max_length
=
50
,
null
=
True
,
blank
=
True
)
class
Meta
:
ordering
=
(
'name'
,)
...
...
tests/lookup/tests.py
Dosyayı görüntüle @
feb683c4
...
...
@@ -5,6 +5,7 @@ from operator import attrgetter
from
django.core.exceptions
import
FieldError
from
django.db
import
connection
from
django.db.models.functions
import
Substr
from
django.test
import
TestCase
,
skipUnlessDBFeature
from
.models
import
Article
,
Author
,
Game
,
Player
,
Season
,
Tag
...
...
@@ -878,3 +879,19 @@ class LookupTests(TestCase):
season
=
Season
.
objects
.
create
(
year
=
2012
,
nulled_text_field
=
None
)
self
.
assertTrue
(
Season
.
objects
.
filter
(
pk
=
season
.
pk
,
nulled_text_field__isnull
=
True
))
self
.
assertTrue
(
Season
.
objects
.
filter
(
pk
=
season
.
pk
,
nulled_text_field
=
''
))
def
test_pattern_lookups_with_substr
(
self
):
a
=
Author
.
objects
.
create
(
name
=
'John Smith'
,
alias
=
'Johx'
)
b
=
Author
.
objects
.
create
(
name
=
'Rhonda Simpson'
,
alias
=
'sonx'
)
tests
=
(
(
'startswith'
,
[
a
]),
(
'istartswith'
,
[
a
]),
(
'contains'
,
[
a
,
b
]),
(
'icontains'
,
[
a
,
b
]),
(
'endswith'
,
[
b
]),
(
'iendswith'
,
[
b
]),
)
for
lookup
,
result
in
tests
:
with
self
.
subTest
(
lookup
=
lookup
):
authors
=
Author
.
objects
.
filter
(
**
{
'name__
%
s'
%
lookup
:
Substr
(
'alias'
,
1
,
3
)})
self
.
assertCountEqual
(
authors
,
result
)
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