#35539: SearchVector GinIndex raises IMMUTABLE error
----------------------------------+------------------------------------
     Reporter:  Alastair D'Silva  |                    Owner:  (none)
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  5.0
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  1                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------
Changes (by Sarah Boyce):

 * cc: Mariusz Felisiak, Simon Charette (added)
 * stage:  Unreviewed => Accepted
 * summary:
     contrib/postgres/search.py COALESCE breaks GIN Index creation on
     PostgreSQL 15
     => SearchVector GinIndex raises IMMUTABLE error

Comment:

 Thank you for the report, was able to replicate the error 👍
 I believe this is a valid bug, I've never used these before myself but
 looks like it's being used
 [https://docs.djangoproject.com/en/5.0/ref/contrib/postgres/search/#performance
 as documented]

 Here is my "rough" test if it gives anyone a starting point

 {{{#!diff
 --- a/tests/postgres_tests/test_indexes.py
 +++ b/tests/postgres_tests/test_indexes.py
 @@ -379,6 +379,19 @@ class SchemaTests(PostgreSQLTestCase):
              editor.remove_index(Scene, index)
          self.assertNotIn(index_name,
 self.get_constraints(Scene._meta.db_table))

 +    def test_search_vector_gin_index(self):
 +        index_name = "search_vector_gin"
 +        index = GinIndex(SearchVector("field"), name=index_name)
 +        with connection.schema_editor() as editor:
 +            editor.add_index(TextFieldModel, index)
 +        table = TextFieldModel._meta.db_table
 +        constraints = self.get_constraints(table)
 +        self.assertIn(index_name, constraints)
 +        self.assertIn(constraints[index_name]["type"], GinIndex.suffix)
 +        with connection.schema_editor() as editor:
 +            editor.remove_index(TextFieldModel, index)
 +        self.assertNotIn(index_name, self.get_constraints(table))
 +
      def test_cast_search_vector_gin_index(self):
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35539#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701903634c0f2-ccaaedd2-6ad1-42bb-bc0f-b172cdc1eb5e-000000%40eu-central-1.amazonses.com.

Reply via email to