tickets: 2495
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2495 | 2006-08-07 16:34:30 | 2015-08-27 13:26:35 | 2022-03-06 03:26:09.944518 | Accepted | closed | Database layer (models, ORM) | Bug | Normal | dev | wontfix | db.models.TextField cannot be marked unique when using mysql backend | 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. | Honza_Kral | anonymous | mysql TextField | 0 | 1 | 0 | 0 | 0 | 0 |