mirror of
https://github.com/django/django.git
synced 2025-07-28 23:54:02 +00:00
Fixed #35732 -- Wrapped ConcatPair expression in parentheses to ensure operator precedence.
When ConcatPair was updated to use || this lost the implicit wrapping from CONCAT(...).
This broke the WHERE clauses when used in combination with PostgreSQL trigram similarity.
Regression in 6364b6ee10
.
Co-authored-by: Emiliano Cuenca <106986074+emicuencac@users.noreply.github.com>
This commit is contained in:
parent
38c2065154
commit
c3ca6075cc
3 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,6 @@
|
|||
from django.db.models import F, Value
|
||||
from django.db.models.functions import Concat
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
from .models import CharFieldModel, TextFieldModel
|
||||
|
||||
|
@ -149,6 +152,21 @@ class TrigramTest(PostgreSQLTestCase):
|
|||
],
|
||||
)
|
||||
|
||||
def test_trigram_concat_precedence(self):
|
||||
search_term = "im matthew"
|
||||
self.assertSequenceEqual(
|
||||
self.Model.objects.annotate(
|
||||
concat_result=Concat(
|
||||
Value("I'm "),
|
||||
F("field"),
|
||||
output_field=self.Model._meta.get_field("field"),
|
||||
),
|
||||
)
|
||||
.filter(concat_result__trigram_similar=search_term)
|
||||
.values("field"),
|
||||
[{"field": "Matthew"}],
|
||||
)
|
||||
|
||||
|
||||
class TrigramTextFieldTest(TrigramTest):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue