[Django] #28161: contrib.postgres: ArrayField(CITextField) returns string instead of list

33 views
Skip to first unread message

Django

unread,
May 2, 2017, 7:53:08 AM5/2/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
--------------------------------------------+------------------------
Reporter: Hendrik Richter | Owner: (none)
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: 1.11
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 |
--------------------------------------------+------------------------
The following code

{{{
from django.db import models
from django.contrib.postgres.fields import ArrayField, CITextField

class Foo(models.Model):
bar = ArrayField(models.TextField)
baz = ArrayField(CITextField())
}}}

has this wrong behaviour:

{{{
x = Foo.objects.get(id=1)
x.bar # => ["Foo", "Bar"]
x.baz # => "{Foo,Bar}"
}}}

This is due to https://github.com/psycopg/psycopg2/issues/268 which
requires registering a new adapter for citext fields:

Use

{{{
select typarray from pg_type where typname = 'citext';
}}}

to get the oid, then do

{{{
psycopg2.extensions.register_type(
psycopg2.extensions.new_array_type(
(the_returned_oid,), 'citext[]', psycopg2.STRING))
}}}

for the correct behaviour in plain psycopg2.

Django should do that automatically if any of the CI*Fields is used.
Alternatively, the ArrayField should convert the result string manually to
the proper list.

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

Django

unread,
May 2, 2017, 10:49:08 AM5/2/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
----------------------------------+------------------------------------

Reporter: Hendrik Richter | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

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

* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

We'll have to do
[https://github.com/django/django/blob/d0e43f225f59145903c72c650eeef1f80e12f9ed/django/contrib/postgres/apps.py#L19-L20
the same thing we do for hstore].

Marking as release blocker because it's a bug in a newly introduced
feature.

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

Django

unread,
May 2, 2017, 8:56:40 PM5/2/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* status: new => assigned
* owner: (none) => Simon Charette


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

Django

unread,
May 3, 2017, 1:28:25 AM5/3/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8453 PR]

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

Django

unread,
May 3, 2017, 1:31:27 PM5/3/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.11
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
May 3, 2017, 2:33:12 PM5/3/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hendrik Richter):

Replying to [comment:3 Simon Charette]:
> [https://github.com/django/django/pull/8453 PR]

Thank you for the quick fix, that helps a lot :-) Awesome!

--
Ticket URL: <https://code.djangoproject.com/ticket/28161#comment:5>

Django

unread,
May 4, 2017, 12:19:55 AM5/4/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette <charette.s@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b91868507af08234a30e9a8e7c90b37c561ba315" b9186850]:
{{{
#!CommitTicketReference repository=""
revision="b91868507af08234a30e9a8e7c90b37c561ba315"
Fixed #28161 -- Fixed return type of ArrayField(CITextField()).

Thanks Tim for the review.
}}}

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

Django

unread,
May 4, 2017, 12:25:35 AM5/4/17
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Simon Charette <charette.s@…>):

In [changeset:"246166cfe4d5d054fcef452c5af2d0b0e5f37151" 246166cf]:
{{{
#!CommitTicketReference repository=""
revision="246166cfe4d5d054fcef452c5af2d0b0e5f37151"
[1.11.x] Fixed #28161 -- Fixed return type of ArrayField(CITextField()).

Thanks Tim for the review.

Backport of b91868507af08234a30e9a8e7c90b37c561ba315 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28161#comment:7>

Django

unread,
Jan 31, 2019, 1:44:04 PM1/31/19
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a8b03bea180e0660c0e159f3e7cf6192b512925f" a8b03bea]:
{{{
#!CommitTicketReference repository=""
revision="a8b03bea180e0660c0e159f3e7cf6192b512925f"
Refs #28161 -- Doc'd INSTALLED_APPS requirement for ArrayField(CIText).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28161#comment:8>

Django

unread,
Jan 31, 2019, 1:44:06 PM1/31/19
to django-...@googlegroups.com
#28161: contrib.postgres: ArrayField(CITextField) returns string instead of list
-------------------------------------+-------------------------------------
Reporter: Hendrik Richter | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"953067d8dcb62baba22c0a5f607b5e1d08099f51" 953067d8]:
{{{
#!CommitTicketReference repository=""
revision="953067d8dcb62baba22c0a5f607b5e1d08099f51"
[2.2.x] Refs #28161 -- Doc'd INSTALLED_APPS requirement for
ArrayField(CIText).

Backport of a8b03bea180e0660c0e159f3e7cf6192b512925f from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28161#comment:9>

Reply all
Reply to author
Forward
0 new messages