#32300: "BIGINT UNSIGNED value is out of range" occurs when substraction 
operation
between PositiveBigIntegerField and BigIntegerField using F()
-------------------------------------+-------------------------------------
     Reporter:  jun                  |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  mysql unsigned       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * keywords:  F expression => mysql unsigned
 * status:  new => closed
 * resolution:   => wontfix


Comment:

 It can be worked around by using an explicit `Cast` expression


 {{{#!python
 qs.update(big_int_column=Cast(F('positive_big_int_column'),
 BigIntegerField()) - F('big_int_column'))
 }}}

 But you risk data corruption if `positive_big_int_column` is larger than
 what MySQL allows storing an a signed `bigint`. PostgreSQL and Oracle
 backends don't suffer from that as they implement
 `PositiveBigIntegerField` using a check constraint.
 [https://www.sqlite.org/datatype3.html SQLite simply have an integer type]
 without constraints at all so it's also not affected.

 I'll close as ''wontfix'' as it's really just a MySQL quirk due to the
 usage of `UNSIGNED` data types to implement `PositiveIntegerField`
 variants. I guess there isn't much that can be done until we drop support
 for MySQL < 8 since the latter introduces `CHECK` constraints support.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32300#comment:2>
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/066.193033e97a9ba2add6bf71e0d19b83f2%40djangoproject.com.

Reply via email to