#28047 closed Bug (fixed)
QuerySet.filter() using the name of a OneToOneField primary key crashes
Reported by: | Thierry Bastian | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Release blocker | Keywords: | regression |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I have this (simplified)
from django.db import models class Foo(models.Model): class Meta: app_label = 'inventory' pass class Bar(models.Model): class Meta: app_label = 'inventory' foo = models.OneToOneField(Foo, primary_key=True, on_delete=models.CASCADE)
Of course you need an app named inventory. But just use this and try to create a query set like this:
Bar.objects.filter(foo__in=Foo.objects.all())
Obviously I had different criteria.
Creating that query set says:
"django.core.exceptions.FieldError: Cannot resolve keyword 'foo' into field. Choices are: bar, id"
That was working just fine in Django 1.10
Attachments (1)
Change History (7)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 8 years ago
Summary: | Regression in query set against 1.10 → QuerySet.filter() using the name of a OneToOneField primary key crashes |
---|
by , 8 years ago
Attachment: | 28047-test.diff added |
---|
Note:
See TracTickets
for help on using tickets.
Regression in 1bc249c2a67c24fcd28436c85388eff1d826e305.
A test to reproduce is attached.