#24169: ArrayField can't use __contained_by or __overlap queries for CharField
----------------------------------+--------------------------------------
     Reporter:  joelburton        |                    Owner:
         Type:  Uncategorized     |                   Status:  new
    Component:  contrib.postgres  |                  Version:  1.8alpha1
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  1                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Changes (by joelburton):

 * needs_docs:   => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Old description:

> ArrayField's lookup.py uses the @> operator for __contains, the <@
> operator for __contained_by, and the && operator for __overlap.
>
> When the field uses CharField (Postgres' varchar()), __contains works,
> but __contained_by and __overlap do not, as Postgres does not define <@
> and && operators for an array of varchar[] (it does for text[]).
>
> __contains works because, in array.py, there is a custom lookup,
> "ArrayOverlap", the outputs a cast to cast the array query value to, say,
> "::varchar(10)[]"
>
> If there are similar custom lookups for __contained_by and __overlap,
> these then work.

New description:

 ArrayField's lookup.py uses the @> operator for !__contains, the <@
 operator for !__contained_by, and the && operator for !__overlap.

 When the field uses CharField (Postgres' varchar()), !__contains works,
 but !__contained_by and !__overlap do not, as Postgres does not define <@
 and && operators for an array of varchar[] (it does for text[]).

 !__contains works because, in array.py, there is a custom lookup,
 "ArrayOverlap", the outputs a cast to cast the array query value to, say,
 "::varchar(10)[]"

 If there are similar custom lookups for !__contained_by and !__overlap,
 these then work.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/24169#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.50fa7fd7b20f4b2c3adad49e3cc2341f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to