From 4342882a52aa6e76c8180fef26ad999b6c044426 Mon Sep 17 00:00:00 2001 From: ACMCMC <20495460+ACMCMC@users.noreply.github.com> Date: Tue, 23 Nov 2021 09:55:27 +0100 Subject: [PATCH] Solved multiword MySQL search bug --- wagtail/search/backends/database/mysql/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtail/search/backends/database/mysql/query.py b/wagtail/search/backends/database/mysql/query.py index 4fb370f9fe..cef077529e 100644 --- a/wagtail/search/backends/database/mysql/query.py +++ b/wagtail/search/backends/database/mysql/query.py @@ -103,7 +103,7 @@ class CombinedLexeme(LexemeCombinable): rsql, params = compiler.compile(self.rhs) value_params.extend(params) - combined_sql = '{}{} {}{}'.format(lhs_connector, lsql, rhs_connector, rsql) # if self.connector is '+' (AND), then both terms will be ANDed together. We need to repeat the connector to make that work. + combined_sql = '({}{} {}{})'.format(lhs_connector, lsql, rhs_connector, rsql) # if self.connector is '+' (AND), then both terms will be ANDed together. We need to repeat the connector to make that work. combined_value = combined_sql % tuple(value_params) return '%s', [combined_value]