Opened 7 years ago
Closed 6 years ago
#28767 closed Bug (fixed)
Incorrect value when annotating empty list as Value() on ArrayField.
Reported by: | Matthew Schinckel | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 2.2 |
Severity: | Normal | Keywords: | annotate |
Cc: | Tomer Chachamu | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a nice simple minimal case that shows this.
You can try this on any model: auth.User was just convenient for example. You'll need at least one object in there to query.
from django.contrib.auth.models import User from django.contrib.postgres.fields import ArrayField from django.db.models.expressions import Value from django.db.models import IntegerField User.objects.annotate(foo=Value([1], output_field=ArrayField(IntegerField()))).first().foo # Outputs [1], as expected User.objects.annotate(foo=Value([], output_field=ArrayField(IntegerField()))).first().foo # Outputs '{}', which is _not_ correct.
Change History (6)
comment:2 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
#28762 may be related if not a duplicate.
comment:3 by , 7 years ago
I added a test in #28762 for this.
Version 0, edited 7 years ago by (next)
comment:4 by , 7 years ago
Cc: | added |
---|
comment:6 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Version: | 1.11 → 2.2 |
Fixed in 3af695eda24b874486ee8be7e0d729761b3bdc71.
Note:
See TracTickets
for help on using tickets.
Still a problem in current development head.