Opened 4 years ago
Last modified 3 years ago
#32297 assigned Bug
QuerySet.get() method not working as expected with Window functions — at Version 1
Description (last modified by ) ¶
I have a simple model as below,
class Employee(models.Model): name = models.CharField(max_length=40, blank=False, null=False) salary = models.PositiveIntegerField() department = models.CharField(max_length=40, blank=False, null=False) hire_date = models.DateField(blank=False, null=False) age = models.IntegerField(blank=False, null=False) bonus = models.DecimalField(decimal_places=2, max_digits=15, null=True)
and I queried
qs = Employee.objects.annotate( rank=Window(expression=Rank(), order_by=F("salary").desc()), )
and then I have called the get()
method to get the rank of a single specific object
qs.get(pk=pk).rank
Issue
The get(pk=pk).rank
returning a constant value irrespective of the kwargs
applied to the get()
method
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.