rmcepeda / django-survey

Automatically exported from code.google.com/p/django-survey
0 stars 0 forks source link

syncdb raises exception #24

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
./manage.py syncdb

What is the expected output? What do you see instead?

_mysql_exceptions.OperationalError: (1170, "BLOB/TEXT column 'text' used in
key specification without a key length")

What version of the product are you using? On what operating system?

Trunk on OSX with MySQL5

Please provide any additional information below.

Looking at ./manage.py sqlall survey I longtext `text` field might be the
culprit:

CREATE TABLE `survey_question` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `survey_id` integer NOT NULL,
    `qtype` varchar(2) NOT NULL,
    `required` bool NOT NULL,
    `text` longtext NOT NULL,
    `order` integer NULL,
    `image` varchar(100) NULL,
    `choice_num_min` integer NULL,
    `choice_num_max` integer NULL,
    `qstyle` longtext NULL,
    `_order` integer NULL,
    UNIQUE (`survey_id`, `text`)
)

Trying to UNIQUE a longtext field ... the attached patch seems to have
fixed it but only by using a varchar. patch also includes a typo fix.

Original issue reported on code.google.com by mand...@gmail.com on 2 Oct 2008 at 11:26

Attachments:

GoogleCodeExporter commented 8 years ago
This is a Django bug caused by a MySQL limitation:
http://code.djangoproject.com/ticket/2495

Basically, MySQL's complaining because it won't let you index a whole BLOB. The
workaround is to leave the UNIQUE off and add the index later using an ALTER 
table
command. 

Original comment by dev@simon.net.nz on 7 Oct 2008 at 3:54

GoogleCodeExporter commented 8 years ago
This should already be fixed (thank to brosner)

Original comment by doug.nap...@gmail.com on 17 Oct 2008 at 4:29

GoogleCodeExporter commented 8 years ago
oops, confused this with something else.
This issue has yet to be fixed in django.
I am still not comfortable marking the text field non-unique.

Original comment by doug.nap...@gmail.com on 17 Oct 2008 at 4:33

GoogleCodeExporter commented 8 years ago
Still a problem with MySQL that should be fixed in the DJango cod, but hasn't 
been. 
Problem has been around since Jun 2008

Comment out the unique_together(...) call, syncdb, then turn it back on.....

Can't find any docs on unique_together, but if you could specify a keylength, 
maybe
this could be fixed here.....

Original comment by Mark0...@gmail.com on 27 Dec 2008 at 7:14

GoogleCodeExporter commented 8 years ago
This problem still exists.  I followed the approach from mandric in the original
post--that is, I changed the TextField to a CharField with a max_length of 500.

Original comment by conrad...@gmail.com on 28 Aug 2009 at 3:53

GoogleCodeExporter commented 8 years ago
it is needed to limit UNIQUE keys like that:
    UNIQUE (`survey_id`, `text`(100))

Original produces 
    UNIQUE (`survey_id`, `text`)
and mysql does not allow UNIQUE keys more than 1000 byte.

Modified sql is attached. Or do like that

$ /manage.py sqlall survey > survey.sql

and open and change lines below in survey.sql

    UNIQUE (`survey_id`, `text`)
to
    UNIQUE (`survey_id`, `text`(100))

and

    UNIQUE (`question_id`, `text`)
to
    UNIQUE (`question_id`, `text`(100))

and save survey.sql and execute this file with your mysql client app on your 
database.

Original comment by ali.r.ke...@gmail.com on 10 Mar 2010 at 11:24

Attachments:

GoogleCodeExporter commented 8 years ago
Hey ... why I'm still having this problem ?

Original comment by raonygui...@gmail.com on 4 Jul 2011 at 3:59

GoogleCodeExporter commented 8 years ago
Hey ... why I'm still having this problem ?

Original comment by raonygui...@gmail.com on 4 Jul 2011 at 3:59