Opened 5 years ago

Closed 5 years ago

Last modified 5 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 Changed 5 years ago by Erik Cederstrand

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:2 Changed 5 years ago by Dmitry Dygalo

Has patch: set

comment:3 Changed 5 years ago by Simon Charette

#25091 was a duplicate.

comment:4 Changed 5 years ago by Iacopo Spalletti

Triage Stage: UnreviewedAccepted

comment:5 Changed 5 years ago by Dmitry Dygalo

Owner: set to Dmitry Dygalo
Status: newassigned

comment:6 Changed 5 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:7 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 263b3d2b:

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

comment:8 Changed 5 years ago by Tim Graham <timograham@…>

In e9c9f2ed:

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

Backport of 263b3d2ba132ea443193dc0b728741317742c8d3 from master

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

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