#32770: GinIndex with OpClass and Cast results in Postgres syntax error in
migration
-------------------------------------+-------------------------------------
     Reporter:  Seth Yastrov         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Hannes Ljungberg (added)
 * resolution:   => worksforme
 * status:  new => closed
 * component:  Migrations => Database layer (models, ORM)
 * easy:  1 => 0


Comment:

 Extra parentheses shouldn't be an issue on PostgreSQL. Also I cannot
 reproduce this crash on PostgreSQL 12.6, see the following test.
 {{{
     def test_trigram_op_class_cast_gin_index(self):
         index_name = 'trigram_op_class_castgin'
         index = GinIndex(OpClass(Cast('id', CharField(max_length=255)),
 name='gin_trgm_ops'), name=index_name)
         with connection.schema_editor() as editor:
             editor.add_index(Scene, index)
         with editor.connection.cursor() as cursor:
             cursor.execute(self.get_opclass_query, [index_name])
             self.assertCountEqual(cursor.fetchall(), [('gin_trgm_ops',
 index_name)])
         constraints = self.get_constraints(Scene._meta.db_table)
         self.assertIn(index_name, constraints)
         self.assertIn(constraints[index_name]['type'], GinIndex.suffix)
         with connection.schema_editor() as editor:
             editor.remove_index(Scene, index)
         self.assertNotIn(index_name,
 self.get_constraints(Scene._meta.db_table))
 }}}
 {{{
 CREATE INDEX "trigram_op_class_castgin" ON "postgres_tests_scene" USING
 gin ((CAST("id" AS varchar(255))) gin_trgm_ops)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32770#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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.39ba18b0b4b85f0dfc2f53d22c81785c%40djangoproject.com.

Reply via email to