honzakral/django-threadedcomments

DatabaseError: (1170, "BLOB/TEXT column 'tree_path' used in key specification without a key length")

Closed this issue · 9 comments

We are getting the following error when running south migrations after implementing threadedcomments. I see a much older bug like this logged, and the problem at that time was Django indexing. Has this been resolved since?

This had something to do with the use of the text model field for tree_path. I resolved it by changing its type to CharField(max_length=255) - in theory you should be able to use any length you like though.

The error is coming because MySQL can index only the first N chars of a BLOB or TEXT column. So you must be having a field/column type of TEXT or BLOB that you are trying to make as primary key or index.

With full BLOB or TEXT without the length value, MySQL will be unable to guarantee the uniqueness of the column as it’s of variable and dynamic size. So, when using BLOB or TEXT types as index, the value of N must be supplied so that MySQL can determine the key length.

I saw this, it looked like ThreadedComments module was doing this? The error was around the ThreadedComments - Tree_path field?

Exactly, with regard to mysql

Same issue here

Same issue here with mysql. Is it fair to say this package is broken for mysql users? I tried changing the tree_path to CharField(max_length=255) but that produces this warning:

Failed to install index for threadedcomments.ThreadedComment model: Duplicate index 'threadedcomments_comment_05bb2fd1' defined on the table 'iw.threadedcomments_comment'. This is deprecated and will be disallowed in a future release.

Edit: Have gone for a custom solution as I can't work out what's going wrong and I don't want problems down the line.

I am running into the same issue when trying to run the test for the app -

FATAL ERROR - The following SQL query failed: CREATE INDEX threadedcomments_comment_928d31e4 ON threadedcomments_comment (tree_path);
The error was: (1170, "BLOB/TEXT column 'tree_path' used in key specification without a key length")
! Error found during real run of migration! Aborting.

any solution for this?

I'm having the same issue too.

This is now fixed in django-threadedcomments 1.0b1. We've replaced the TextField with a CharField, that MySQL can apply indexes at.