id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 2188,[patch] Older versions of MySQL cannot handle varchars > 255 characters in length.,Fraser Nevett ,Adrian Holovaty,"== The problem == Versions of MySQL below 5.0.3 only support {{{varchar}}} fields with a maximum length of 255 characters (see the [http://dev.mysql.com/doc/refman/5.0/en/char.html MySQL docs] for details). When Django is generating the create SQL for a !CharField, !CommaSeparatedIntegerField or !SlugField it uses the {{{maxlength}}} attribute to specify the {{{varchar}}} length. This clearly has the potential to produce SQL which is not accepted by older (yet still very popular and prevalent) versions of MySQL. == Possible solutions == As I see it, there are three options to address this: 1. document this as a known issue and leave it up to developers to deal with the problem manually; 2. detect the problem when validating the model and display an error to the user telling them they can't have a {{{maxlength}}} > 255; or 3. detect the problem when creating the database and use the {{{text}}} data type (instead of {{{varchar}}}) when {{{maxlength}}} > 255. == Pros and cons of the solutions == I think option one would be the minimum, but really isn't that helpful and doesn't deal with the problem itself. I don't think this is the way to go. Option two would stop the problem from occurring, but is obviously restrictive and wouldn't allow you the freedom to easily switch between database backends. The use of the {{{text}}} data type in option three pretty much removes any restrictions on the {{{maxlength}}} of a field, but may have undesired performance issues -- does MySQL treat {{{varchar}}}s and {{{text}}}s differently? Also, since {{{text}}} does not have a length specified, MySQL would not perform length validation when inserting or updating data. == What now? == I attach patches for options two and three, and will leave it to your judgement as to which would be more appropriate and in keeping with the Django ethos.",defect,closed,"Database layer (models, ORM)",dev,normal,fixed,,,Unreviewed,1,0,0,0,0,0