#34858: Output field for combined PositiveIntegerField is not properly resolved.
-------------------------------------+-------------------------------------
     Reporter:  Toan Vuong           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Simon Charette, Luke Plant (added)
 * type:  Uncategorized => Bug
 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for the ticket. This is not strictly related with Oracle, the main
 issue is that `output_field` is not properly resolved for a combination of
 `PositiveIntegerField`. `Coalesce()` on Oracle checks the `output_field`
 of arguments and crashes. We should be able to fix this but prioritize
 `PositiveIntegerField`, e.g.
 {{{#!diff
 diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 index 4ea179ecde..54edaa611c 100644
 --- a/django/db/models/expressions.py
 +++ b/django/db/models/expressions.py
 @@ -512,6 +512,23 @@ class Expression(BaseExpression, Combinable):

  _connector_combinations = [
      # Numeric operations - operands of same type.
 +    {
 +        # PositiveIntegerField should take precedence over IntegerField.
 +        connector: [
 +            (
 +                fields.PositiveIntegerField,
 +                fields.PositiveIntegerField,
 +                fields.PositiveIntegerField,
 +            ),
 +        ]
 +        for connector in (
 +            Combinable.ADD,
 +            Combinable.MUL,
 +            Combinable.DIV,
 +            Combinable.MOD,
 +            Combinable.POW,
 +        )
 +    },
      {
          connector: [
              (fields.IntegerField, fields.IntegerField,
 fields.IntegerField),

 }}}

 Would you like to prepare a patch (via GitHub PR)? a regression test is
 required.


 Regression in 40b8a6174f001a310aa33f7880db0efeeb04d4c4 (#33397).

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34858#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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ab6b65569-3145cab2-282e-4055-84db-03cbc9dce181-000000%40eu-central-1.amazonses.com.

Reply via email to