#12404: Improve max_length validation
------------------------------------------+---------------------------------
 Reporter:  tiliv                         |       Owner:  nobody    
   Status:  new                           |   Milestone:  1.2       
Component:  Database layer (models, ORM)  |     Version:  SVN       
 Keywords:  max_length, validation        |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 Absentmindedly I wrote a line like the following in a model, where I
 accidentally contracted the definition of max_length and help_text into a
 single keyword arg:

 {{{
     field = models.CharField(max_length="This field is really cool. Not to
 mention this message.")
 }}}

 My accidental value for max_length is not being validated to check and see
 if it is indeed an integer for use in a MySQL varchar field definition.
 The SQL created during {{{ ./manage.py syncdb }}} is as follows, which
 causes the error also following:

 {{{
     `field` varchar(This field is really cool. Not to mention this
 message.) NOT NULL
 }}}
 {{{
     _mysql_exceptions.ProgrammingError: (1064, "You have an error in your
 SQL syntax;
     check the manual that corresponds to your MySQL server version for the
 right
     syntax to use near 'This field is really cool. Not to mention this
 message.) NOT NULL\n)'
     at line 4")
 }}}

 Improved validation might simply try casting the value of max_length to an
 integer before proceeding.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12404>
Django <http://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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to