#32297: QuerySet.get() method not working as expected with Window functions
-------------------------------------+-------------------------------------
     Reporter:  Jerin Peter George   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Jerin Peter George:

Old description:

> I have a simple model as below,
>

> {{{
> class Employee(models.Model):
>     name = models.CharField(max_length=40, blank=False, null=False)
>     salary = models.PositiveIntegerField()
> }}}
>
> 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

New description:

 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

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32297#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.1b8ab6f4c85ef53a03ec6845d270eebd%40djangoproject.com.

Reply via email to