[Django] #28767: Incorrect value when annotating empty list as Value() on ArrayField.

45 views
Skip to first unread message

Django

unread,
Nov 2, 2017, 11:28:05 PM11/2/17
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
---------------------------------------------+--------------------------
Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Keywords: annotate
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+--------------------------
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.
}}}

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

Django

unread,
Nov 2, 2017, 11:33:22 PM11/2/17
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+--------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:

Keywords: annotate | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Matthew Schinckel):

It's still a problem on 2.0 beta 1.

--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:1>

Django

unread,
Nov 4, 2017, 6:37:30 PM11/4/17
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: annotate | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

#28762 may be related if not a duplicate.

--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:2>

Django

unread,
Nov 5, 2017, 7:48:10 AM11/5/17
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: annotate | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Tomer Chachamu):

I added a test in #28762 for this.

--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:3>

Django

unread,
Dec 2, 2017, 7:53:57 PM12/2/17
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: annotate | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tomer Chachamu):

* cc: Tomer Chachamu (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:4>

Django

unread,
Apr 18, 2019, 6:07:38 AM4/18/19
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:
Keywords: annotate | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

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>

Django

unread,
Apr 18, 2019, 6:08:54 AM4/18/19
to django-...@googlegroups.com
#28767: Incorrect value when annotating empty list as Value() on ArrayField.
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: closed
Component: contrib.postgres | Version: 2.2
Severity: Normal | Resolution: fixed

Keywords: annotate | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by felixxm):

* status: new => closed
* version: 1.11 => 2.2
* resolution: => fixed


Comment:

Fixed in 3af695eda24b874486ee8be7e0d729761b3bdc71.

--
Ticket URL: <https://code.djangoproject.com/ticket/28767#comment:6>

Reply all
Reply to author
Forward
0 new messages