Code

Opened 3 years ago

Closed 3 years ago

#16688 closed Bug (duplicate)

unionagg doesn't respect limits

Reported by: arc <django-bugs@…> Owned by: nobody
Component: GIS Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When specifying a limit with slice syntax and then running unionagg, this limit is not taken into account. In the below example, unionagg is run on the entire set of records rather than only 10 records as expected:

qs = Model.objects.all()[:10]
ua = qs.unionagg()

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Slicing a QuerySet basically tacks "LIMIT foo" at the end of the generated SQL. As a consequence, the slicing applies after the aggregation.

The same problem is handled properly in the case of filter: MyModel.objects.filter(...)[:10].filter(...) raises AssertionError: Cannot filter a query once a slice has been taken.

I think aggregating a query after a slice has been taken should also raise an AssertionError.

comment:2 Changed 3 years ago by anonymous

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #15101 (Extent aggregate instead).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.