Re: [Django] #32117: Aggregation doesnt work with Models, ordered by Meta subclass

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #32117: Aggregation doesnt work with Models, ordered by Meta subclass

Django
#32117: Aggregation doesnt work with Models, ordered by Meta subclass
-------------------------------------+-------------------------------------
     Reporter:  eloktev              |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Uncategorized        |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:  aggregation,         |             Triage Stage:
  database, psycopg2                 |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by eloktev:

Old description:

> Hello,
> Using aggregation methods with models, that have set 'ordering' in Meta
> subclass fails:
> {{{
> class M1 (models.Model)
>     date = models.DateField()
>     smth = models.IntegerField()
>
>     class Meta:
>         ordeing = 'smth'
> }}}
>
> {{{{
> count_by_day_qs =
> M1.objects.values('date').annotate(c=models.Count('id')).values('date',
> 'c')
> }}}}
> Returns executes following query:
> {{{{
> SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY
> "m1"."date", "m1"."smth"
> }}}}
New description:

 Hello,
 Using aggregation methods with models, that have set 'ordering' in Meta
 subclass fails:
 {{{
 class M1 (models.Model)
     date = models.DateField()
     smth = models.IntegerField()

     class Meta:
         ordeing = 'smth'

 count_by_day_qs =
 M1.objects.values('date').annotate(c=models.Count('id')).values('date',
 'c')
 }}}}
 Returns executes following query:
 {{{{
 SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY
 "m1"."date", "m1"."smth"
 }}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32117#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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.241e204159964c93cddcdb13207e0456%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #32117: Aggregation doesnt work with Models, ordered by Meta subclass

Django
#32117: Aggregation doesnt work with Models, ordered by Meta subclass
-------------------------------------+-------------------------------------
     Reporter:  eloktev              |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Uncategorized        |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:  aggregation,         |             Triage Stage:
  database, psycopg2                 |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by eloktev:

Old description:

> Hello,
> Using aggregation methods with models, that have set 'ordering' in Meta
> subclass fails:
> {{{
> class M1 (models.Model)
>     date = models.DateField()
>     smth = models.IntegerField()
>
>     class Meta:
>         ordeing = 'smth'
>
> count_by_day_qs =
> M1.objects.values('date').annotate(c=models.Count('id')).values('date',
> 'c')
> }}}}
> Returns executes following query:
> {{{{
> SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY
> "m1"."date", "m1"."smth"
> }}}}
New description:

 Hello,
 Using aggregation methods with models, that have set 'ordering' in Meta
 subclass fails:
 {{{
 class M1 (models.Model)
     date = models.DateField()
     smth = models.IntegerField()

     class Meta:
         ordeing = 'smth'

 count_by_day_qs =
 M1.objects.values('date').annotate(c=models.Count('id')).values('date',
 'c')

 #Executes following query:
 SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY
 "m1"."date", "m1"."smth"

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:2>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.0a25dfa1693a4f9de226855f5df0baa1%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #32117: Aggregation doesnt work with Models, ordered by Meta subclass

Django
In reply to this post by Django
#32117: Aggregation doesnt work with Models, ordered by Meta subclass
-------------------------------------+-------------------------------------
     Reporter:  eloktev              |                    Owner:  Dede Dian
         Type:  Uncategorized        |                   Status:  assigned
    Component:  Uncategorized        |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:  aggregation,         |             Triage Stage:
  database, psycopg2                 |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Dede Dian):

 * owner:  nobody => Dede Dian
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:3>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.c4d083969eabfad35206eb7b523a36d6%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #32117: Aggregation doesnt work with Models, ordered by Meta subclass

Django
In reply to this post by Django
#32117: Aggregation doesnt work with Models, ordered by Meta subclass
-------------------------------------+-------------------------------------
     Reporter:  eloktev              |                    Owner:  Dede Dian
         Type:  Uncategorized        |                   Status:  closed
    Component:  Uncategorized        |                  Version:  3.1
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  aggregation,         |             Triage Stage:
  database, psycopg2                 |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * status:  assigned => closed
 * resolution:   => invalid


Comment:

 This is documented as a caveat of performing aggregation against a model
 with a defined `Meta.ordering`

 https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#interaction-
 with-default-ordering-or-order-by

 Please TicketClosingReasons/UseSupportChannels before filling a ticket in
 the future.

--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.ab38c3f16741285fe30b5a1325b0443d%40djangoproject.com.