[Django] #26321: Missing "for_save" in examples of custom PostgreSQL aggregates

5 views
Skip to first unread message

Django

unread,
Mar 3, 2016, 6:31:29 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom PostgreSQL aggregates
-------------------------------+--------------------------------
Reporter: tomaszn | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Keywords: postgres aggregate
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------
Example at [https://docs.djangoproject.com/en/dev/ref/models/expressions
/#writing-your-own-query-expressions] doesn't work:
{{{
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "xxx/django/db/models/query.py", line 909, in annotate
clone.query.add_annotation(annotation, alias, is_summary=False)
File "xxx/django/db/models/sql/query.py", line 974, in add_annotation
summarize=is_summary)
File "xxx/django/db/models/aggregates.py", line 19, in
resolve_expression
c = super(Aggregate, self).resolve_expression(query, allow_joins,
reuse, summarize)
File "xxx/django/db/models/expressions.py", line 534, in
resolve_expression
c.source_expressions[pos] = arg.resolve_expression(query, allow_joins,
reuse, summarize, for_save)
TypeError: resolve_expression() takes at most 5 arguments (6 given)
}}}
Adding "for_save" parameter to the method signature and calls fixes this
issue.
Please find the patch attached.

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

Django

unread,
Mar 3, 2016, 6:31:54 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom PostgreSQL aggregates
--------------------------------+----------------------------

Reporter: tomaszn | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Resolution:

Keywords: postgres aggregate | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 0
UI/UX: 0 |
--------------------------------+----------------------------
Changes (by tomaszn):

* Attachment "fixed_postgres_custom_agg_example.patch" added.

Django

unread,
Mar 3, 2016, 6:53:40 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom PostgreSQL aggregates
------------------------------------+--------------------------------------

Reporter: tomaszn | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Resolution:

Keywords: postgres aggregate | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by tomaszn):

* needs_better_patch: => 0
* needs_tests: => 0
* easy: 0 => 1
* needs_docs: => 0


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

Django

unread,
Mar 3, 2016, 6:57:36 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom expression
-------------------------------+------------------------------------

Reporter: tomaszn | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Resolution:
Keywords: expressions | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by jarshwah):

* keywords: postgres aggregate => expressions
* stage: Unreviewed => Accepted


Comment:

I've renamed the case because this is about custom expressions, not
specifically about postgres or aggregates (which don't actually use
for_save). Patch looks mostly fine to me. Would you mind submitting it as
a PR on GitHub? That'll allow review and the automated tests to run.

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

Django

unread,
Mar 3, 2016, 7:35:20 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom expression
-------------------------------------+-------------------------------------

Reporter: tomaszn | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.9
Severity: Normal | Resolution:
Keywords: expressions | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


Comment:

`for_save` was added in 65246de7b1d70d25831ab394c4f4a75813f629fe, so I'll
backport to the 1.8 docs. No need to submit a PR really.

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

Django

unread,
Mar 3, 2016, 7:38:14 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom expression
-------------------------------------+-------------------------------------
Reporter: tomaszn | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: expressions | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"de8a11ba18d5902c668d4db47c38c9c6bdf9c1da" de8a11ba]:
{{{
#!CommitTicketReference repository=""
revision="de8a11ba18d5902c668d4db47c38c9c6bdf9c1da"
Fixed #26321 -- Added missing "for_save" parameter in expressions example.

Thanks tomaszn for the patch.
}}}

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

Django

unread,
Mar 3, 2016, 7:38:17 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom expression
-------------------------------------+-------------------------------------
Reporter: tomaszn | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: expressions | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"377ca697a133e6063be3dff09b83b1c533d91950" 377ca697]:
{{{
#!CommitTicketReference repository=""
revision="377ca697a133e6063be3dff09b83b1c533d91950"
[1.9.x] Fixed #26321 -- Added missing "for_save" parameter in expressions
example.

Thanks tomaszn for the patch.

Backport of de8a11ba18d5902c668d4db47c38c9c6bdf9c1da from master
}}}

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

Django

unread,
Mar 3, 2016, 7:38:24 PM3/3/16
to django-...@googlegroups.com
#26321: Missing "for_save" in examples of custom expression
-------------------------------------+-------------------------------------
Reporter: tomaszn | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: expressions | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"8b891cf3862658b6b297063b3efeb81f1985cda3" 8b891cf]:
{{{
#!CommitTicketReference repository=""
revision="8b891cf3862658b6b297063b3efeb81f1985cda3"
[1.8.x] Fixed #26321 -- Added missing "for_save" parameter in expressions
example.

Thanks tomaszn for the patch.

Backport of de8a11ba18d5902c668d4db47c38c9c6bdf9c1da from master
}}}

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

Reply all
Reply to author
Forward
0 new messages