Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32967 closed Bug (wontfix)

Buggy Migrations when `float("nan")` in `Q` objects — at Version 3

Reported by: Steven Jin Owned by: Steven Jin
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: db Q
Cc: Steven Jin Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Steven Jin)

When creating a CheckConstraint in the form

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

Change History (3)

comment:1 by Steven Jin, 3 years ago

Description: modified (diff)

comment:2 by Steven Jin, 3 years ago

Summary: Buggy Migrations when `flota("nan")` in `Q` objectsBuggy Migrations when `float("nan")` in `Q` objects

comment:3 by Steven Jin, 3 years ago

Cc: Steven Jin added
Description: modified (diff)
Has patch: set
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top