#28120: CharField: if max_length=True (or False): makemigrations generates a
migration and migrate fails
-------------------------------------+-------------------------------------
     Reporter:  Carles Pina Estany   |                    Owner:  Carles
                                     |  Pina Estany
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Дилян Палаузов):

 What about ensuring that max_length is an int, and not bool this way:
 {{{
 diff --git a/django/db/models/fields/__init__.py
 b/django/db/models/fields/__init__.py
 --- a/django/db/models/fields/__init__.py
 +++ b/django/db/models/fields/__init__.py
 @@ -1045,8 +1045,7 @@ class CharField(Field):
                      id='fields.E120',
                  )
              ]
 -        elif (not isinstance(self.max_length, int) or
 isinstance(self.max_length, bool) or
 -                self.max_length <= 0):
 +        elif type(self.max_length) != int or self.max_length <= 0:
              return [
                  checks.Error(
                      "'max_length' must be a positive integer.",

 }}}

 There are more places in the code that check for {{{not isinstance(...,
 int)}}}.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28120#comment:7>
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/063.961bde2b01c32c29a495cc66d39ab75c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to