Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"afceb2241ba84dfafe59de326cdc9c01963ddefb" afceb22]:
 {{{
 #!CommitTicketReference repository=""
 revision="afceb2241ba84dfafe59de326cdc9c01963ddefb"
 [3.0.x] Fixed #31566 -- Fixed aliases crash when chaining
 values()/values_list() after annotate() with aggregations and subqueries.

 Subquery annotation references must be resolved if they are excluded
 from the GROUP BY clause by a following .values() call.

 Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.

 Thanks Makina Corpus for the report.

 Backport of 42c08ee46539ef44f8658ebb1cbefb408e0d03fe from master
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.a6fcd88cf0ad25b0c83ffe58ea3ca779%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"8cb87a3f7c413b9943a5a73e156716067267b182" 8cb87a3f]:
 {{{
 #!CommitTicketReference repository=""
 revision="8cb87a3f7c413b9943a5a73e156716067267b182"
 [3.1.x] Fixed #31566 -- Fixed aliases crash when chaining
 values()/values_list() after annotate() with aggregations and subqueries.

 Subquery annotation references must be resolved if they are excluded
 from the GROUP BY clause by a following .values() call.

 Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.

 Thanks Makina Corpus for the report.

 Backport of 42c08ee46539ef44f8658ebb1cbefb408e0d03fe from master
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.5d2a007526915e624b553fcadc94bd2b%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"42c08ee46539ef44f8658ebb1cbefb408e0d03fe" 42c08ee4]:
 {{{
 #!CommitTicketReference repository=""
 revision="42c08ee46539ef44f8658ebb1cbefb408e0d03fe"
 Fixed #31566 -- Fixed aliases crash when chaining values()/values_list()
 after annotate() with aggregations and subqueries.

 Subquery annotation references must be resolved if they are excluded
 from the GROUP BY clause by a following .values() call.

 Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.

 Thanks Makina Corpus for the report.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.74aea8a6df9f9e889a7ccb29126a09ef%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.28ba706220f4392b842645c36c3ad541%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by felixxm):

 Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.eb34a862fc948d8690a539387060e1a1%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-13 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * has_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.4f180bcf1732d800c2c0ccd7bc949133%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-12 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Gagaro):

 I had tested it on 3.0.6 and stable/3.0.x branch. I didn't try it with two
 `annotate` but felixxm just did.

 Thanks for taking care of it so quickly.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c615c31c20ca9a87ffaa359fe537ba06%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-11 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by felixxm):

 Simon, I can reproduce this at 46fe506445666d8097945f0c1e8be11cfd644b28,
 also with two `annotate()` calls.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.373cb0d30611c90b6c9d94667586af56%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-11 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 Out of curiosity, does the error happens against 3.0.6 as well and can you
 also reproduce by breaking your `.annotate` call in two: a first one for
 the `start_time=Min("datetime")` and a following one for the `Exists`?

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.eb7af02b0688002383e9771f9a847e15%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-11 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  Simon
 |  Charette
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * owner:  nobody => Simon Charette
 * status:  new => assigned


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.ea5fe311a4b1621d02ac97d25c31b200%40djangoproject.com.


Re: [Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-11 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
 Reporter:  Gagaro   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  3.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted


Comment:

 This is similar #31377, we'll want to ensure the alias is part of
 `annotation_select_mask`.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.6e39cd06f223534f979828b5c8fbcb7b%40djangoproject.com.


[Django] #31566: Subquery in annotation is included by its alias and is not present in the SELECT

2020-05-11 Thread Django
#31566: Subquery in annotation is included by its alias and is not present in 
the
SELECT
-+-
   Reporter:  Gagaro |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Database   |Version:  3.0
  layer (models, ORM)|
   Severity:  Normal |   Keywords:
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 With the following queryset:

 {{{
 IndicatorValue.objects
 .values("freight")
 .annotate(
 
has_top_loading=Exists(OrderItemResult.objects.order_by().filter(order_line__order__freight=OuterRef("freight"),
 loading_arm__loading_type=LoadingArm.LOADING_TYPE_TOP,).values('pk')),
 start_time=Min("datetime")
 )
 .values('start_time')
 }}}

 I have the following error:

 {{{
 ProgrammingError: column "has_top_loading" does not exist
 LINE 1: ...ROUP BY "indicators_indicatorvalue"."freight_id", "has_top_l...
 }}}

 The generated SQL is:

 {{{
 SELECT MIN("indicators_indicatorvalue"."datetime") AS "start_time"
 FROM "indicators_indicatorvalue"
 GROUP BY "indicators_indicatorvalue"."freight_id", "has_top_loading"
 }}}

 `has_top_loading` is only mentioned in the `GROUP_BY` and not in the
 `SELECT`.

 On Django 2.2, the same queryset generates the following SQL:

 {{{
 SELECT MIN("indicators_indicatorvalue"."datetime") AS "start_time"
 FROM "indicators_indicatorvalue"
 GROUP BY "indicators_indicatorvalue"."freight_id", (EXISTS(SELECT U0."id"
 FROM "orders_orderitemresult" U0 INNER JOIN "loading_terminal_loadingarm"
 U1 ON (U0."loading_arm_id" = U1."id") INNER JOIN "orders_orderitem" U2 ON
 (U0."order_line_id" = U2."id") INNER JOIN "orders_order" U3 ON
 (U2."order_id" = U3."id") WHERE (U1."loading_type" = TOP AND
 U3."freight_id" = ("indicators_indicatorvalue"."freight_id"
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.cea36085df6a71d048082f095b509560%40djangoproject.com.