Re: [Django] #36051: Declare arity on aggregate functions

13 views
Skip to first unread message

Django

unread,
Jan 5, 2025, 12:49:52 AMJan 5
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

> Super helpful. I'll update #36042 to do as you describe here, and then
we can refocus this ticket on adding arity checks to aggregates, since it
sounds like we have consensus on that (and that doesn't have to land in
5.2).

That makes sense!

> Certainly there is a difference between those two calls, but on the main
branch the unpacking was already happening, i.e. Max(F("pk")) already
compiles to Max(col1, col2), not Max((col1, col2))

`Max("pk")` (we can drop the explicit `F`) compiles to `MAX(col1, col2)`
at the SQL level due to the quirky way `ColPairs.as_sql` is implemented to
support `SELECT` and `GROUP BY` references on backends that don't have
native `ROW` / tuple support but it ''resolves'' to `Max(ColPairs("col1",
"col2"))` which is a distinction that makes me believe we should not use
`arity` and unpacking for this purpose.

> Thanks for letting me kick the tires (this is helping me get more
comfortable with the ORM internals!)

Happy my feedback is useful, thanks for your time spent making the
composite primary key usage experience better. The current awkwardness
around `ColPairs.as_sql` and `Tuple` will vanish once we have proper
support for composite fields but there might be a way to simplify things
before that by getting rid of the the hacky way `SELECT` and `GROUP BY`
deal with `ColPairs` compilation. I'll see if I can get something working
tomorrow.
--
Ticket URL: <https://code.djangoproject.com/ticket/36051#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 5, 2025, 10:20:52 AMJan 5
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(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 Jacob Walls):

* needs_better_patch: 1 => 0

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

Django

unread,
Jan 13, 2025, 11:51:01 AMJan 13
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(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 Sarah Boyce):

* stage: Accepted => Ready for checkin

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

Django

unread,
Jan 13, 2025, 12:07:44 PMJan 13
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

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

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

Django

unread,
Jan 13, 2025, 10:02:22 PMJan 13
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(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 Jacob Walls):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36051#comment:9>

Django

unread,
Jan 14, 2025, 6:49:44 AMJan 14
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(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 Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36051#comment:10>

Django

unread,
Jan 14, 2025, 10:47:21 AMJan 14
to django-...@googlegroups.com
#36051: Declare arity on aggregate functions
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: New feature | Status: closed
Component: Database layer | Version: dev
(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 Sarah Boyce <42296566+sarahboyce@…>):

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

Comment:

In [changeset:"d206d4c200d71c0847e7f6720d88c587e7b46843" d206d4c]:
{{{#!CommitTicketReference repository=""
revision="d206d4c200d71c0847e7f6720d88c587e7b46843"
Fixed #36051 -- Declared arity on aggregate functions.

Follow-up to 4a66a69239c493c05b322815b18c605cd4c96e7c.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36051#comment:11>
Reply all
Reply to author
Forward
0 new messages