#33901: non-deterministic collations doesn't work with Unique=True on
Postgres13.3
-------------------------------------+-------------------------------------
Reporter: DrChai | Owner: nobody
Type: Bug | Status: new
Component: | Version: 4.0
Migrations | Keywords: collation unique
Severity: Normal | citext
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Creating a non-deterministic collation used for case insensitive fields to
replace the old approach,
[https://docs.djangoproject.com/en/4.0/ref/contrib/postgres/fields
/#citext-fields CIText], would raise `django.db.utils.NotSupportedError:
nondeterministic collations are not supported for operator class
"varchar_pattern_ops"` when the `unique=True` is also set on the
field.Since unique implies the creation of an index despite setting
`db_index=False` explicitly.
here is a sample code to reproduce:
{{{
#!python
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
CreateCollation(
'ci',
provider='icu',
locale='und-u-ks-level2',
deterministic=False
),
migrations.CreateModel(
name='TestgUser',
fields=[
('id', models.BigAutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128,
verbose_name='password')),
('username', models.CharField(db_collation='ci',
max_length=30, unique=True, verbose_name='username')),
],
options={
'verbose_name': 'Test User',
'verbose_name_plural': 'Test Users',
'abstract': False,
},
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33901>
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/0107018274dd0e4a-a5d8e1d3-64da-472b-af11-fddc55d4173d-000000%40eu-central-1.amazonses.com.