Opened 11 years ago

Closed 11 years ago

#20170 closed Bug (needsinfo)

LIMIT works on entire queryset, even when not expected to.

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: ManyToManyField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Class MyParent(models.Model):
    x = models.IntegerField()

Class MyChild(models.Model):
    parent = models.ForeignKey(MyParent)
    y      = models.IntegerField()

x = MyModel1.objects.all()[:5]
x.values('x', 'mychild')

The resulting queryset will possibly return less than 5 objects and then possibly not all of their children (because it adds 'LIMIT 5' to the entire SQL query instead of making one query with 'LIMIT 5' and another one with the join).

Change History (2)

comment:1 by zeevro@…, 11 years ago

comment:2 by Luke Plant, 11 years ago

Resolution: needsinfo
Status: newclosed

I cannot understand the example code - it seems to have several errors. Can you post a corrected example, and re-open? I'm struggling to understand what the bug is as well, and what join you are referring to.

Note: See TracTickets for help on using tickets.
Back to Top