Not Working: ArrayField(models.CharField(max_length=200), blank=True)
Working: ArrayField(models.TextField(blank=True))
--
Ticket URL: <https://code.djangoproject.com/ticket/29171>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:1>
Comment (by Simon Charette):
Could you provide a traceback and more details about how ''it fails''?
Does it happen when you define a model using `ArrayField(CharField())`,
when performing a query annotation?
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:2>
Comment (by Pal):
Replying to [comment:2 Simon Charette]:
> Could you provide a traceback and more details about how ''it fails''?
>
> Does it happen when you define a model using `ArrayField(CharField())`,
when performing a query annotation?
Yes. When I defined the model as shown in the documentation at
https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields
/#querying-arrayfield , the query fails. But if I change models.CharField
to models.TextField, the query succeeds.
Here are the error statements from apache2 error log:
psycopg2.ProgrammingError: operator does not exist: text[] @> character
varying[]
django.db.utils.ProgrammingError: operator does not exist: text[] @>
character varying[]
May be we need to change the documentation to reflect the change above.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:3>
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:4>
Comment (by Tim Graham):
Please show the model and the query. Perhaps you could write it as a test
for `tests/postgres_tests/test_array.py` using `CharArrayModel`.
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:5>
Comment (by Pal):
Replying to [comment:5 Tim Graham]:
> Please show the model and the query. Perhaps you could write it as a
test for `tests/postgres_tests/test_array.py` using `CharArrayModel`.
One thing I want to mention is that this table was already created in
Postgres and I am adding that to the models.py and as I said if I define
as ArrayField(models.CharField...) it does not work where as
ArrayField(models.TextField...) works. So someone can test and verify
this. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:6>
Comment (by Tim Graham):
I'm still not sure we have enough details to reproduce the issue. What
does the SQL for the table look like, what does your model look like, and
what does the failing QuerySet look like?
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:7>
* status: new => closed
* resolution: => worksforme
--
Ticket URL: <https://code.djangoproject.com/ticket/29171#comment:8>