#23791: Subqueries with non-"id" OneToOneField primary keys try to join against
the
wrong column name
-------------------------------------+-------------------------------------
Reporter: ris | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: orm primary_key
Severity: Normal | OneToOneField subquery values
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hi, your favourite ORM obscure-query bug reporter again here...
Using Django 1.7.1 & postgres, example models.py:
{{{
class ModelA ( models.Model ):
x = models.TextField ()
class ModelB ( models.Model ):
a = models.OneToOneField ( ModelA , primary_key = True )
}}}
issuing the query
{{{
>>> ModelC.objects.filter ( pk__in = ModelC.objects.filter ( a__x = "abc"
) )
}}}
results in
{{{
FieldError: Cannot resolve keyword u'id' into field. Choices are: a, a_id
}}}
A workaround exists:
{{{
>>> ModelC.objects.filter ( pk__in = ModelC.objects.filter ( a__x = "abc"
).values ( "pk" ) )
}}}
which behaves correctly.
--
Ticket URL: <https://code.djangoproject.com/ticket/23791>
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/046.a3048dd69d1deb4931b45184ddaa3834%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.