On 7 déc, 23:46, germ <mitch.german...@gmail.com> wrote:
> my platform: django 1.1.1, mysql 5.0.67, python 2.6.2
>
> why does syncdb complain
>  CharField cannot have a "max_length" greater than 255 when using
> "unique=True"
>
> when mysql 5.0.67 does allow greater tan 255? is there a way to
> override or ignore this error?
>
> this works in mysql
> mysql> create table mbg_test_1 (id int(5), url varchar(760) not null,
> primary key (id), unique (url));
> Query OK, 0 rows affected (0.00 sec)
>
>
> not sure why django hits this error since the true max length is 767,
> not 255:
>
> mysql> create table mbg_test_1 (url varchar(999) not null, unique (url));
> ERROR 1071 (42000): Specified key was too long; max key length is 767
> bytes

Are you sure you're using the same encoding (charset) in both cases ?
Note that the above message says "767 *bytes*", not 767 *characters*

Here is what I have (mysql 5.0.75):

mysql> create table mbg_test_1 (url varchar(767) not null, unique
(url)) CHARACTER SET utf8;
ERROR 1071 (42000): Specified key was too long; max key length is 1000
bytes

The point is that utf8 can use up to 3 bytes per character...

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to