#36210: Support queries where lhs is CompositePrimaryKey and rhs is Subquery
-------------------------------------+-------------------------------------
               Reporter:  Jacob      |          Owner:  Jacob Walls
  Walls                              |
                   Type:  New        |         Status:  assigned
  feature                            |
              Component:  Database   |        Version:  5.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This query is not currently supported (models drawn from composite_pk test
 suite):
 {{{
 subquery = Subquery(User.objects.filter(pk=OuterRef("pk")).values("pk"))
 queryset = Comment.objects.filter(pk=subquery)
 }}}
 ----
 {{{#!py
   File "/django/source/django/db/models/fields/tuple_lookups.py", line 56,
 in get_prep_lookup
     self.check_rhs_is_supported_expression()
   File "/django/source/django/db/models/fields/tuple_lookups.py", line 79,
 in check_rhs_is_supported_expression
     raise ValueError(
 ValueError: 'exact' subquery lookup of 'pk' only supports OuterRef and
 QuerySet objects (received 'Subquery')
 }}}
 ----
 The version without explicit `Subquery` (and adding `[:1]`) also fails:
 {{{
   File "/django/source/django/db/models/lookups.py", line 384, in
 get_prep_lookup
     raise ValueError(
 ValueError: The QuerySet value for the exact lookup must have 2 selected
 fields (received 1)
 }}}

 On Oracle the failure looks like this, but this is probably a separate
 issue:

 {{{#!py
 django.db.utils.DatabaseError: ORA-01796: this operator cannot be used
 with lists
 Help: https://docs.oracle.com/error-help/db/ora-01796/
 }}}
 ----
 [https://github.com/django/django/pull/19206 PR] to kick off discussion
 addresses all but the Oracle failure, which might worth looking at
 separately, perhaps a deeper issue?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36210>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019533af5df2-065e4b67-c5b6-4428-b89b-36e17274bf01-000000%40eu-central-1.amazonses.com.

Reply via email to