Opened 4 years ago
Last modified 2 years ago
#32297 assigned Bug
QuerySet.get() method not working as expected with Window functions — at Version 1
Reported by: | Jerin Peter George | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Mariusz Felisiak, Simon Charette | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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
Note:
See TracTickets
for help on using tickets.