#23801: IntegerField w/ max_length silently truncates integers
----------------------------------------------+--------------------
     Reporter:  eykd                          |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 An IntegerField with a max_length silently truncates integers. Observe:

 {{{
 >>> class MyModel(Model):
 >>>    num = IntegerField(max_length=2)

 >>> m = MyModel.objects.create(num=42)
 >>> m.num
 42
 >>> m.num = 427
 >>> m.num
 427
 >>> m.save()
 >>> m.num
 42
 }}}

 This violates the Zen of Python: "Errors should never pass silently." It
 has also has been a reliable source of fun bugs over the years. This is
 long-standing Procrustean behavior, since at least v1.0 I think, if not
 before, but it bit me for the nth time yesterday, so I'm filing a bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/23801>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.4ae3bf2f8ee28139a0bae139f3536696%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to