﻿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
2495	db.models.TextField cannot be marked unique when using mysql backend	anonymous	Honza Král	"When I used a field like this:
{{{
text     = models.TextField(maxlength=2048, unique=True)
}}}

it results in the following sql error when the admin app goes to make the table
{{{
_mysql_exceptions.OperationalError: (1170, ""BLOB/TEXT column 'text' used in key specification without a key length"")
}}}

After a bit of investigation, it turns out that mysql refuses to use unique with the column unless it is only for an indexed part of the text field:
{{{
CREATE TABLE `quotes` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,     `text` longtext NOT NULL ,     `submitTS` datetime NOT NULL,     `submitIP` char(15) NOT NULL,     `approved` bool NOT NULL, unique (text(1000))); 
}}}
Of course 1000 is just an arbitrary number I chose, it happens to be the maximum my database would allow.

Not entirely sure how this can be fixed, but I figured it was worth mentioning.
"	Bug	closed	Database layer (models, ORM)	dev	Normal	wontfix	mysql TextField	treborhudson@… martin@… django-ticket-2495@… Almad Chris Chambers em@… eigrad	Accepted	1	0	0	0	0	0
