#32967: Buggy Migrations when `float("nan")` in `Q` objects
-------------------------------------+-------------------------------------
     Reporter:  Steven Jin           |                    Owner:  Steven
                                     |  Jin
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  db Q                 |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Steven Jin):

 * cc: Steven Jin (added)
 * status:  assigned => closed
 * has_patch:  0 => 1
 * resolution:   => fixed


Old description:

> When creating a `CheckConstraint` in the form
>
> {{{#!python
> class MyModel(Model):
>   x = FloatField()
>   class Meta:
>     constraints = [~CheckConstraint(check=Q(x=float("nan")), name="some
> constraint")]
> }}}
>
> This constraint is removed and added back every time `python manage.py
> makemigrations` is run. This is because the inherited `__eq__` function
> of `Q` objects does not take into account the fact that `float("nan") !=
> float("nan")`.

New description:

 When creating a `CheckConstraint` in the form

 {{{#!python
 class MyModel(Model):
   x = FloatField()
   class Meta:
     constraints = [~CheckConstraint(check=Q(x=float("nan")), name="some
 constraint")]
 }}}

 This constraint is removed and added back every time `python manage.py
 makemigrations` is run. This is because the inherited `__eq__` function of
 `Q` objects does not take into account the fact that `float("nan") !=
 float("nan")`.

 See PR: https://github.com/django/django/pull/14706

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32967#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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.7fa9422e683c6fcac6b93fde19ae4395%40djangoproject.com.

Reply via email to