[Django] #29066: Sum does not support __neg__

48 views
Skip to first unread message

Django

unread,
Jan 25, 2018, 3:43:32 PM1/25/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Pava |
Type: Bug | Status: new
Component: Database | Version: master
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 |
-------------------------------------+-------------------------------------
I am trying to negate the sum of values in my model, and the workaround is
to multiply by `Value(-1)`.

I get this error when I try to annotate by `-Sum('field')`:

{{{
TypeError
bad operand type for unary -: 'Sum'
}}}

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

Django

unread,
Jan 25, 2018, 11:01:29 PM1/25/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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):

* stage: Unreviewed => Accepted


Comment:

I guess we could add support for `__neg__`, in the mean time `Sum('field')
* -1` which goes through `__mul__` should work just fine.

--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:1>

Django

unread,
Jan 26, 2018, 12:11:57 AM1/26/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Priyansh Saxena):

* owner: nobody => Priyansh Saxena
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:2>

Django

unread,
Jan 28, 2018, 5:53:37 AM1/28/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Priyansh Saxena):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:3>

Django

unread,
Jan 28, 2018, 4:16:55 PM1/28/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Adam (Chainz) Johnson):

* cc: Adam (Chainz) Johnson (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:4>

Django

unread,
Jan 29, 2018, 3:44:53 AM1/29/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Priyansh Saxena):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:5>

Django

unread,
Jan 30, 2018, 10:09:02 AM1/30/18
to django-...@googlegroups.com
#29066: Sum does not support __neg__
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Adam (Chainz) Johnson):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:6>

Django

unread,
Jan 31, 2018, 10:55:27 AM1/31/18
to django-...@googlegroups.com
#29066: Allow negating query expressions

-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:7>

Django

unread,
Jan 31, 2018, 11:28:03 AM1/31/18
to django-...@googlegroups.com
#29066: Allow negating query expressions
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Priyansh
| Saxena
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"617d5f410fdd5c491c929e5d66ce6f5aa95e45ee" 617d5f41]:
{{{
#!CommitTicketReference repository=""
revision="617d5f410fdd5c491c929e5d66ce6f5aa95e45ee"
Fixed #29066 -- Allowed negating query expressions.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29066#comment:8>

Reply all
Reply to author
Forward
0 new messages