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
8b25d546
Kaydet (Commit)
8b25d546
authored
Mar 07, 2018
tarafından
Mariusz Felisiak
Kaydeden (comit)
Tim Graham
Mar 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplified Contains, StartsWith, and EndsWith lookups.
üst
f0d6f01f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
32 deletions
+11
-32
lookups.py
django/db/models/lookups.py
+11
-32
No files found.
django/db/models/lookups.py
Dosyayı görüntüle @
8b25d546
...
...
@@ -376,6 +376,7 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
class
PatternLookup
(
BuiltinLookup
):
param_pattern
=
'
%%%
s
%%
'
def
get_rhs_op
(
self
,
connection
,
rhs
):
# Assume we are in startswith. We need to produce SQL like:
...
...
@@ -393,18 +394,18 @@ class PatternLookup(BuiltinLookup):
else
:
return
super
()
.
get_rhs_op
(
connection
,
rhs
)
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
self
.
param_pattern
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
Contains
(
PatternLookup
):
lookup_name
=
'contains'
prepare_rhs
=
False
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
"
%%%
s
%%
"
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
IContains
(
Contains
):
...
...
@@ -415,50 +416,28 @@ class IContains(Contains):
@Field.register_lookup
class
StartsWith
(
PatternLookup
):
lookup_name
=
'startswith'
param_pattern
=
'
%
s
%%
'
prepare_rhs
=
False
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
"
%
s
%%
"
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
IStartsWith
(
PatternLookup
):
class
IStartsWith
(
StartsWith
):
lookup_name
=
'istartswith'
prepare_rhs
=
False
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
"
%
s
%%
"
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
EndsWith
(
PatternLookup
):
lookup_name
=
'endswith'
param_pattern
=
'
%%%
s'
prepare_rhs
=
False
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
"
%%%
s"
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
IEndsWith
(
PatternLookup
):
class
IEndsWith
(
EndsWith
):
lookup_name
=
'iendswith'
prepare_rhs
=
False
def
process_rhs
(
self
,
qn
,
connection
):
rhs
,
params
=
super
()
.
process_rhs
(
qn
,
connection
)
if
params
and
not
self
.
bilateral_transforms
:
params
[
0
]
=
"
%%%
s"
%
connection
.
ops
.
prep_for_like_query
(
params
[
0
])
return
rhs
,
params
@Field.register_lookup
class
Range
(
FieldGetDbPrepValueIterableMixin
,
BuiltinLookup
):
...
...
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