Changes between Version 1 and Version 2 of Ticket #34160, comment 10


Ignore:
Timestamp:
Nov 16, 2022, 1:09:53 PM (18 months ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34160, comment 10

    v1 v2  
    11What I believe is happening here is that `F("inventory_count") + Value(1)` has its `output_field` resolved to `IntegerField` because it's the common base of `inventory_count` (which I assume is a `SmallIntegerField` since the models were not provided) and `Value(1)`.
    22
    3 While `CombinedExpression._resolve_output_field` resolving logic deals with subclassing properly `BaseExpression._resolve_output_field` [https://github.com/django/django/blob/2848e5d0ce5cf3c31fe87525536093b21d570f69/django/db/models/expressions.py#L327-L329 isn't smart enough] to resolve a mix of `IntegerField` subclasses to the largest denominator.
     3While `CombinedExpression._resolve_output_field` resolving logic deals with subclassing properly `BaseExpression._resolve_output_field` [https://github.com/django/django/blob/2848e5d0ce5cf3c31fe87525536093b21d570f69/django/db/models/expressions.py#L327-L329 isn't smart enough] to resolve a mix of `IntegerField` subclasses to the largest denominator. By smart I mean that there isn't a proper way do this at such a low level for all subclasses of `BaseExpression` hence [https://github.com/django/django/blob/2848e5d0ce5cf3c31fe87525536093b21d570f69/django/db/models/expressions.py#L327-L329 why it's considered a bad idea to event try doing so].
    44
    55The three ways we could be fixing that would be:
Back to Top