Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-27 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Rohit Jha
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  db,outerref,group| Triage Stage:  Ready for
  by,subquery,annotate   |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"486786c4c480f5b1ae3ac1c95858b03699b9eb9c" 486786c]:
 {{{
 #!CommitTicketReference repository=""
 revision="486786c4c480f5b1ae3ac1c95858b03699b9eb9c"
 Fixed #31251 -- Disabled grouping by OuterRef() annotation.
 }}}

-- 
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.56471f3171636948e1c6d36f97b3835e%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-26 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Rohit Jha
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Rohit Jha):

 * cc: Rohit Jha (added)
 * needs_tests:  1 => 0


Comment:

 Tests => ​https://github.com/django/django/pull/12489

-- 
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.00cb05793f2f7fdcf4df85fed51d38b2%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-24 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Rohit Jha
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Simon Charette):

 * needs_better_patch:  0 => 1
 * needs_tests:  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.42be38fc97a74fdbdb872fb153a230d2%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-24 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Rohit Jha
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Rohit Jha):

 * 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.5e699e87d3c5c1787c206ef650e92b63%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-14 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Rohit Jha
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Rohit Jha):

 * owner:  (none) => Rohit Jha
 * 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.f171bceb9abda293f57d17963d7cb311%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-12 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  (none)
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Yuri Savin):

 Replying to [comment:5 felixxm]:
 > Oliver, `OuterRef()` is a field from the outer query, so it will be the
 same for all rows in a subquery. Is there any value in adding it to a
 `GROUP BY` clause? e.g.
 > {{{
 > (SELECT MIN("price") from "subquery_table" GROUP BY
 "outer_table"."type")
 > }}}
 > is equivalent to
 > {{{
 > (SELECT MIN("price") from "subquery_table")
 > }}}

 I think you can close this ticket better than i'm

-- 
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.26be5760b8611054c37b4764188e78e1%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-12 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  (none)
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Yuri Savin):

 * owner:  Yuri Savin => (none)
 * status:  assigned => new


-- 
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.bc86efe9eed87957749b2ec3ae339758%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-10 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Yuri
 Type:   |  Savin
  Cleanup/optimization   |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by felixxm):

 Oliver, `OuterRef()` is a field from the outer query, so it will be the
 same for all rows in a subquery. Is there any value in adding it to a
 `GROUP BY` clause? e.g.
 {{{
 (SELECT MIN("price") from "subquery_table" GROUP BY "outer_table"."type")
 }}}
 is equivalent to
 {{{
 (SELECT MIN("price") from "subquery_table")
 }}}

-- 
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.bad7c11592913b5e6c33f3efcd7bfe89%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-10 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Yuri
 Type:   |  Savin
  Cleanup/optimization   |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Oliver Ford):

 Why not the column that `OuterRef` is referencing? That was my intended
 behaviour, though I eventually realised I was overcomplicating it and just
 needed to group on the column directly, not an outer ref, and filter on
 the outer ref.

-- 
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.ea00889d681afc650d4dcf004eb62ef9%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef().

2020-02-10 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  Yuri
 Type:   |  Savin
  Cleanup/optimization   |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Yuri Savin):

 * owner:  nobody => Yuri Savin
 * 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.fd4754b52b58d7842e860799eb17bf5e%40djangoproject.com.


Re: [Django] #31251: QuerySet.annotate() crashes when grouping by OuterRef(). (was: Unable to annotate a query that has an OuterRef already)

2020-02-10 Thread Django
#31251: QuerySet.annotate() crashes when grouping by OuterRef().
-+-
 Reporter:  Oliver Ford  |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  db,outerref,group| Triage Stage:  Accepted
  by,subquery,annotate   |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * type:  Bug => Cleanup/optimization
 * version:  3.0 => master
 * easy:  0 => 1
 * stage:  Unreviewed => Accepted


Comment:

 Grouping by `OuterRef()` doesn't have much value, it's like using a
 constant value, so IMO we can easily fix this with:
 {{{
 diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 index 2e831b21ac..a165923784 100644
 --- a/django/db/models/expressions.py
 +++ b/django/db/models/expressions.py
 @@ -562,6 +562,9 @@ class ResolvedOuterRef(F):
  def relabeled_clone(self, relabels):
  return self

 +def get_group_by_cols(self, alias=None):
 +return []
 +

  class OuterRef(F):
  def resolve_expression(self, *args, **kwargs):
 }}}

-- 
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.68c63fdcd9873490c8fc4377a03933c6%40djangoproject.com.