Re: [Django] #35079: Meta indexes/constraints with OpClass on expressions crash. (was: Django Migration with OpClass and varchar_pattern_ops creates an invalid migration SQL)

4 views
Skip to first unread message

Django

unread,
Jan 2, 2024, 5:32:26 AM1/2/24
to django-...@googlegroups.com
#35079: Meta indexes/constraints with OpClass on expressions crash.
--------------------------------+------------------------------------
Reporter: andraantariksa | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 4.2
Severity: Normal | Resolution:
Keywords: migration | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* cc: Lily Foote, Hannes Ljungberg (added)
* stage: Unreviewed => Accepted


Comment:

Thanks for the report. I'm puzzled because almost
[https://github.com/django/django/blob/f412add786dfc18424eee6281ec8cc97220b04fc/tests/postgres_tests/test_constraints.py#L239-L244
the same works] in our test suite and I confirmed that both `Index` and
`UniqueConstraint` crash on:
{{{#!python
class Location(models.Model):
name = models.CharField(max_length=255)
scene = models.TextField(null=True)

class Meta:
indexes = [
models.Index(
OpClass(Upper('name'), name='varchar_pattern_ops'),
name='uppercase_name_index'
),
]
constraints = [
models.UniqueConstraint(
OpClass(Upper("scene"), name="varchar_pattern_ops"),
name="test_opclass_func",
)
]

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35079#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages