Added PatternLookup.prepare_rhs to simplify subclasses.

This commit is contained in:
Simon Charette 2018-03-12 11:58:00 -04:00 committed by Tim Graham
parent 45aaf6608d
commit 3c71fb3909
1 changed files with 1 additions and 6 deletions

View File

@ -377,6 +377,7 @@ class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
class PatternLookup(BuiltinLookup):
param_pattern = '%%%s%%'
prepare_rhs = False
def get_rhs_op(self, connection, rhs):
# Assume we are in startswith. We need to produce SQL like:
@ -404,39 +405,33 @@ class PatternLookup(BuiltinLookup):
@Field.register_lookup
class Contains(PatternLookup):
lookup_name = 'contains'
prepare_rhs = False
@Field.register_lookup
class IContains(Contains):
lookup_name = 'icontains'
prepare_rhs = False
@Field.register_lookup
class StartsWith(PatternLookup):
lookup_name = 'startswith'
param_pattern = '%s%%'
prepare_rhs = False
@Field.register_lookup
class IStartsWith(StartsWith):
lookup_name = 'istartswith'
prepare_rhs = False
@Field.register_lookup
class EndsWith(PatternLookup):
lookup_name = 'endswith'
param_pattern = '%%%s'
prepare_rhs = False
@Field.register_lookup
class IEndsWith(EndsWith):
lookup_name = 'iendswith'
prepare_rhs = False
@Field.register_lookup