#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: <https://code.djangoproject.com/ticket/31251#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 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.