From 3c71fb3909d4fdf6691712dfe84d7b7b8e9fcc35 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Mon, 12 Mar 2018 11:58:00 -0400 Subject: [PATCH] Added PatternLookup.prepare_rhs to simplify subclasses. --- django/db/models/lookups.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py index e5f620eb2c..00eeda1f39 100644 --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -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