summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/base/features.py4
-rw-r--r--django/db/models/lookups.py8
2 files changed, 8 insertions, 4 deletions
diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py
index e8fa82aa21..22c05f28e9 100644
--- a/django/db/backends/base/features.py
+++ b/django/db/backends/base/features.py
@@ -424,6 +424,10 @@ class BaseDatabaseFeatures:
# injection?
prohibits_dollar_signs_in_column_aliases = False
+ # Should PatternLookup.process_rhs() use self.param_pattern? It's unneeded
+ # on databases that don't use LIKE for pattern matching.
+ pattern_lookup_needs_param_pattern = True
+
# A set of dotted paths to tests in Django's test suite that are expected
# to fail on this database.
django_test_expected_failures = set()
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
index 3489fe1e40..eaf3d69a59 100644
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -598,10 +598,10 @@ class PatternLookup(BuiltinLookup):
def process_rhs(self, qn, connection):
rhs, params = super().process_rhs(qn, connection)
if self.rhs_is_direct_value() and params and not self.bilateral_transforms:
- params = (
- self.param_pattern % connection.ops.prep_for_like_query(params[0]),
- *params[1:],
- )
+ param = connection.ops.prep_for_like_query(params[0])
+ if connection.features.pattern_lookup_needs_param_pattern:
+ param = self.param_pattern % param
+ params = (param, *params[1:])
return rhs, params