#36051: Count CompositePrimaryKey field targets toward function arity check
-------------------------------------+-------------------------------------
     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 Simon Charette):

 * cc: Simon Charette (added)

Comment:

 I understand the desire to streamline the composite primary key reference
 experience but this approach just seems plain wrong. Function arity is
 tied to the number of argument passed to a function and `Max(F("pk"))` is
 a single argument where the argument itself is composite.

 In other words, there is a difference between calls of the form `foo(1,
 2)` and `foo((1,2))` (or `foo(bar)` where `bar: int | tuple[int, int]`
 since `F` is a reference) and trying to automatically turn one into the
 other seems like it's going to cause more harm than good.

 What about we merge both #36042 and this ticket under a single one that
 adds a `BaseExpression.allows_composite_expression: bool = False` that we
 set to `True` on `Count` and `TupleLookupMixin` and we make
 `BaseExpression.resolve_expression` raise a `ValueError` when it's set to
 `False` and any of its source expression is an instance of `ColPairs`?

 Don't get me wrong I think we should define `arity` for `Aggregate`
 subclasses to guard against improper calls but I don't think that making
 `Func.resolve_expression` unpack composite expressions is something we
 should do for the aforementioned reasons.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36051#comment:3>
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070194343e531a-ab3d0a9b-544d-4cbc-ae06-a80809298fac-000000%40eu-central-1.amazonses.com.

Reply via email to