Opened 6 years ago

Closed 6 years ago

#22907 closed Bug (fixed)

ArrayField querying doesn't work with CharField

Reported by: Alexander Schepanovski Owned by: Marc Tamlyn <marc.tamlyn@…>
Component: contrib.postgres Version: master
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

When trying to make query with CharArrayModel.objects.filter(field__contains=['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.

Change History (6)

comment:1 Changed 6 years ago by Alexander Schepanovski

Created a failing test in a pull request https://github.com/django/django/pull/2853

comment:2 Changed 6 years ago by Simon Charette

Triage Stage: UnreviewedAccepted

I could reproduce with provided test case on PostgreSQL 9.3.4.

Interestingly I'm also getting a failure on postgres_tests.test_array.TestSaveLoad.test_dates:

ProgrammingError: column "field" is of type timestamp with time zone[] but expression is of type text[]
LINE 1: ...tgres_tests_datetimearraymodel" ("field") VALUES (ARRAY['201...
                                                             ^
HINT:  You will need to rewrite or cast the expression.

@Suor Which version of PostgreSQL are you using?

comment:3 Changed 6 years ago by Aymeric Augustin

Severity: Release blockerNormal

This ticket doesn't block 1.7, probably doesn't block 1.8, and will most likely be fixed by then.

comment:4 Changed 6 years ago by Marc Tamlyn

Has patch: set

comment:5 Changed 6 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 6 years ago by Marc Tamlyn <marc.tamlyn@…>

Owner: set to Marc Tamlyn <marc.tamlyn@…>
Resolution: fixed
Status: newclosed

In b65a2001e7be3811903fc8769fa4d3df3d324f18:

Fixed #22907 -- Array contains must have same type.

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