#33901: non-deterministic collations doesn't work with Unique=True on 
Postgres13.3
-------------------------------------+-------------------------------------
     Reporter:  Ed Chai              |                    Owner:  Ed Chai
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  collation unique     |             Triage Stage:  Ready for
  citext                             |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by kenneweg):

 * status:  closed => new
 * resolution:  fixed =>


Comment:

 the issues can be recreated as follows:

 I have an old migration that sets the field with unique=true

 I have a new migration that sets the field with unique=true,
 db_collation="utf8_unicode_ci"

 The old migration runs first, and creates a LIKE index for the field. The
 new migration attempts to run:
 {{{
 django.db.utils.NotSupportedError: nondeterministic collations are not
 supported for operator class "varchar_pattern_ops"
 }}}


 My work around is writing a DROP INDEX of the LIKE index that is created
 by the first migration

 {{{
         migrations.RunSQL(
             sql="DROP INDEX IF EXISTS
 appname_modelname_fieldname_073c92ac_like;",
             reverse_sql=migrations.RunSQL.noop,
         ),
         migrations.AlterField(
             model_name="modelname",
             name="fieldname",
             field=models.CharField(
                 blank=True, db_collation="utf8_unicode_ci",
 max_length=255, null=True, unique=True
             ),
         ),
 }}}

 But this is quite messy.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33901#comment:18>
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/0107018b1af861a2-5293824f-63eb-4643-af17-456fb13c8339-000000%40eu-central-1.amazonses.com.

Reply via email to