#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:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  F expression         |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by jun:

Old description:

> * Environment
> {{{
> MacOS 0.15.3
> Django 3.1
> MySQL 5.7.32
> mysqlclient==2.0.1
> }}}
>
> * Model
> {{{
> class SomeModel(models.Model):
>     positive_big_int_column = models.PositiveBigIntegerField(default=0)
>     big_int_column = models.BigIntegerField(default=0)
> }}}
>
> * Test
> {{{
> SomeModel.objects.create(positive_big_int_column=100, big_int_column=300)
> qs = SomeModel.objects.filter(positive_big_int_column=100)
> qs.update(big_int_column=F('positive_big_int_column') -
> F('big_int_column'))
> }}}
>
> * Expected query
> UPDATE SomeModel SET big_int_column=(100-300)
>

> * Error
> IntegrityError: (1690, "BIGINT UNSIGNED value is out of range in blabla")

New description:

 * Environment
 {{{
 MacOS 10.15.3
 Django 3.1
 MySQL 5.7.32
 mysqlclient==2.0.1
 }}}

 * Model
 {{{
 class SomeModel(models.Model):
     positive_big_int_column = models.PositiveBigIntegerField(default=0)
     big_int_column = models.BigIntegerField(default=0)
 }}}

 * Test
 {{{
 SomeModel.objects.create(positive_big_int_column=100, big_int_column=300)
 qs = SomeModel.objects.filter(positive_big_int_column=100)
 qs.update(big_int_column=F('positive_big_int_column') -
 F('big_int_column'))
 }}}

 * Expected query
 UPDATE SomeModel SET big_int_column=(100-300)


 * Error
 IntegrityError: (1690, "BIGINT UNSIGNED value is out of range in blabla")

--

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

Reply via email to