Opened 5 years ago

Closed 4 years ago

Last modified 2 years ago

#14707 closed (fixed)

Allow an annotation to match a field name when using .values on a query set.

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

Description

Ticket http://code.djangoproject.com/ticket/11256 has the unfortunate effect of stopping a values query from working.

class Author(models.Model):
  last_updated = models.DateField()

class Book(models.Model):
  author = models.ForeignKey(Author, related_name='books')
  pubdate = models.DateField()
authors = Author.objects.values("id").annotate(last_updated=Max('books__pubdate'))

In this case we are using values to only use that one field and last_updated is no longer overriding anything.

Change History (6)

comment:1 Changed 5 years ago by russellm

  • Component changed from Uncategorized to ORM aggregation
  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Owner nobody deleted
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

This is a regression in trunk, so it needs to be on the 1.3 milestone.

comment:2 Changed 4 years ago by russellm

  • Keywords blocker regression added

comment:3 Changed 4 years ago by russellm

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

(In [15223]) Fixed #14707 -- Relax the protections on aggregate naming collisions when a ValuesQuerySet removes the colliding name. Thanks to Andy McKay for the report.

comment:4 Changed 4 years ago by russellm

(In [15224]) [1.2.X] Fixed #14707 -- Relax the protections on aggregate naming collisions when a ValuesQuerySet removes the colliding name. Thanks to Andy McKay for the report.

Backport of r15223 from trunk.

comment:5 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

comment:6 Changed 2 years ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top