Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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 Erik Cederstrand, 9 years ago

I stumbled upon this because I was trying to edit a unique=True ArrayField via the admin. Before saving, the admin does a check along the lines of CharArrayModel.objects.filter(field=['my_new_text']).exclude(pk=self.pk).

comment:3 by Simon Charette, 9 years ago

#25091 was a duplicate.

comment:4 by Iacopo Spalletti, 9 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Dmitry Dygalo, 9 years ago

Owner: set to Dmitry Dygalo
Status: newassigned

comment:6 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 263b3d2b:

Fixed #25666 -- Fixed the exact lookup of ArrayField.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In e9c9f2ed:

[1.8.x] Fixed #25666 -- Fixed the exact lookup of ArrayField.

Backport of 263b3d2ba132ea443193dc0b728741317742c8d3 from master

comment:9 by Tim Graham <timograham@…>, 9 years ago

In fe79bc3e:

[1.9.x] Fixed #25666 -- Fixed the exact lookup of ArrayField.

Backport of 263b3d2ba132ea443193dc0b728741317742c8d3 from master

Note: See TracTickets for help on using tickets.
Back to Top