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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28767>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Matthew Schinckel):
It's still a problem on 2.0 beta 1.
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:1>
* stage: Unreviewed => Accepted
Comment:
#28762 may be related if not a duplicate.
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:2>
Comment (by Tomer Chachamu):
I added a test in #28762 for this.
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:3>
* cc: Tomer Chachamu (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:4>
Comment (by GitHub <noreply@…>):
In [changeset:"654614b38e09de47e542c5b5d52c194e1d146a39" 654614b3]:
{{{
#!CommitTicketReference repository=""
revision="654614b38e09de47e542c5b5d52c194e1d146a39"
Refs #28767 -- Added test for annotating Value() with empty list as an
ArrayField.
Fixed in 3af695eda24b874486ee8be7e0d729761b3bdc71.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:5>
* status: new => closed
* version: 1.11 => 2.2
* resolution: => fixed
Comment:
Fixed in 3af695eda24b874486ee8be7e0d729761b3bdc71.
--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:6>