Opened 6 years ago
Closed 6 years ago
#30992 closed Bug (duplicate)
missing column in generated SQL at exclude() function call
| Reported by: | wckao | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 2.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
With the following model definitions
from django.db import models
class Audience(models.Model):
name = models.TextField(max_length=10)
class User(models.Model):
audience = models.ForeignKey(Audience, on_delete=models.CASCADE)
class Tracking(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
datetime = models.DateTimeField()
class Conversion(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
datetime = models.DateTimeField()
When issuing the following query
Conversion.objects.exclude(user__audience__user__tracking__datetime__gte=F('datetime'))
the following exception is raised
OperationalError: no such column: U2.id
Note:
See TracTickets
for help on using tickets.
I confirm this was crashing on 2.2 and is passing with f19a4945e1191e1696f1ad8e6cdc6f939c702728 applied which is part of 3.0.
Closing as duplicate of #21703.