Code

Opened 5 years ago

Closed 5 years ago

Last modified 14 months ago

#10666 closed (fixed)

Aggregate with inherited columns does not work as expected

Reported by: julianb Owned by:
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

class Thing(models.Model):
    user = models.ForeignKey("auth.user")
    creation_date = models.DateTimeField(_('Creation date'), default=datetime.datetime.now)
    amount = models.PositiveIntegerField()
    
class Book(Thing):
    blabla = models.ForeignKey("xyz")

# does not work
Book.objects.filter(user=request.user).aggregate(Sum('amount'))
# does work
Book.objects.filter(user=request.user).annotate(Sum('amount'))
# does work
Book.objects.filter(user=request.user).aggregate(Sum('book_ptr__amount'))

Attachments (0)

Change History (4)

comment:1 Changed 5 years ago by Alex

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

comment:2 Changed 5 years ago by russellm

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

(in [10466]) Fixed #10666 -- Corrected the handling of inherited fields with aggregate() and annotate(). Thanks to julienb for the report.

comment:3 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

comment:4 Changed 14 months ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)

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.