#25666 closed Bug (fixed)
ArrayField exact querying doesn't work with CharField
| Reported by: | Erik Cederstrand | Owned by: | Dmitry Dygalo |
|---|---|---|---|
| Component: | contrib.postgres | Version: | 1.8 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
This is a variation of https://code.djangoproject.com/ticket/22907, except with = instead of __contains. When trying to make an exact match on a char ArrayField:
CharArrayModel.objects.filter(field=['text'])
I get:
ProgrammingError: operator does not exist: character varying[] = text[]
LINE 1: ...el" WHERE "postgres_tests_chararraymodel"."field" = ARRAY['...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
The same happens if I use __exact.
Change History (9)
comment:1 by , 10 years ago
comment:4 by , 10 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:5 by , 10 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:6 by , 10 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Note:
See TracTickets
for help on using tickets.
I stumbled upon this because I was trying to edit a
unique=TrueArrayField via the admin. Before saving, the admin does a check along the lines ofCharArrayModel.objects.filter(field=['my_new_text']).exclude(pk=self.pk).