#28664: basic subquery generates invalid sql
-------------------------------------+-------------------------------------
Reporter: David | Owner: nobody
Szotten |
Type: | Status: new
Uncategorized |
Component: Database | Version: master
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 |
-------------------------------------+-------------------------------------
{{{
from django.db import models
class Foo(models.Model):
a = models.IntegerField()
b = models.IntegerField()
class Bar(models.Model):
foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
}}}
{{{
>>> print(Bar.objects.filter(foo=Foo.objects.filter(a=1)).query)
SELECT "app_bar"."id", "app_bar"."foo_id" FROM "app_bar" WHERE
"app_bar"."foo_id" = (SELECT U0."id", U0."a", U0."b" FROM "app_foo" U0
WHERE U0."a" = 1)
}}}
The subquery is selecting all columns, causing
{{{django.db.utils.ProgrammingError: subquery must return only one
column}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28664>
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/055.6a10030eef238f860e7aabdf5f089948%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.