#34160: Django 4.1 Expression contains mixed types for (Big/Small)IntegerFields.
-------------------------------------+-------------------------------------
     Reporter:  Martin Lehoux        |                    Owner:  Martin
                                     |  Lehoux
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 Replying to [comment:15 Mariusz Felisiak]:
 > `Case()` is trying to resolve an output type only for specific fields
 that cannot be implicitly cast on PostgreSQL (namely
 `GenericIPAddressField`, `IPAddressField`, `TimeField`, and `UUIDField`)
 in other cases PostgreSQL does the work, see
 [https://www.postgresql.org/docs/current/typeconv-union-case.html docs].
 As far as I'm aware, we should be safe to ignore errors in resolving an
 output field in other cases:

 After a deeper investigation, this ☝️ only fixes one case:
 {{{#!python
 Case(
     When(Value(True), then=F("small_integer") + Value(1)),
     default=F("integer"),
 )
 }}}
 the following still crashes:
 {{{#!python
 Case(
     When(Value(True), then=F("small_integer") + Value(1)),
     default=F("small_integer"),
 )
 }}}
 I don't think it's worth changing anymore. I theory,
 40b8a6174f001a310aa33f7880db0efeeb04d4c4 is a regression, however the
 previous behavior was also buggy, e.g. `F("small_integer") +
 Value(100000000)` was resolved to `SmallIntegerField`, so I think it
 better to raise an exception in all cases. I'm going to add a small
 release note and close this as "wontfix" when it gets merged.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34160#comment:16>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184c2a625b7-61caad4b-2967-48b7-bb67-95b5ce46d40e-000000%40eu-central-1.amazonses.com.

Reply via email to