summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_trigram.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/postgres_tests/test_trigram.py')
-rw-r--r--tests/postgres_tests/test_trigram.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_trigram.py b/tests/postgres_tests/test_trigram.py
index 812403a324..b6c88c38a6 100644
--- a/tests/postgres_tests/test_trigram.py
+++ b/tests/postgres_tests/test_trigram.py
@@ -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):
"""