#35025: Crash when attempting to order by array index from annotated ArrayAgg
-----------------------------------------+------------------------
Reporter: Ben Nace | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Example models:
{{{
class ModelA(models.Model):
name = models.CharField(max_length=100)
class ModelB(models.Model):
model_a = models.ForeignKey(ModelA, on_delete=models.CASCADE)
value = models.IntegerField()
}}}
And with the following instances:
{{{
modelA = ModelA.objects.create(name='Test')
ModelB.objects.bulk_create([ModelB(model_a=modelA, value=1),
ModelB(model_a=modelA, value=2)])
}}}
The following query results in `AttributeError: 'ArrayField' object has no
attribute 'model'`
{{{
ModelA.objects.values('name').annotate(values=ArrayAgg('modelb__value')).order_by('values__0')
}}}
This crash also happens at least as far back as Django 4.2
--
Ticket URL: <https://code.djangoproject.com/ticket/35025>
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/0107018c459b6e86-39b36b71-6c97-43fb-a513-d134842f76e6-000000%40eu-central-1.amazonses.com.