Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Comments

Primary key can't be text#6

Open
damienkilgannon wants to merge 2 commits intotulir:masterfrom
damienkilgannon:master
Open

Primary key can't be text#6
damienkilgannon wants to merge 2 commits intotulir:masterfrom
damienkilgannon:master

Conversation

@damienkilgannon
Copy link

In order to address the following issue ...

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1170, "BLOB/TEXT column 'md5_digest' used in key specification without a key length") [SQL: '\nCREATE TABLE sent_files (\n\tsession_id VARCHAR(255) NOT NULL, \n\tmd5_digest BLOB NOT NULL, \n\tfile_size INTEGER NOT NULL, \n\ttype INTEGER NOT NULL, \n\tid BIGINT, \n\thash BIGINT, \n\tPRIMARY KEY (session_id, md5_digest, file_size, type)\n)\n\n'] (Background on this error at: http://sqlalche.me/e/e3q8)

@damienkilgannon damienkilgannon changed the title Set size for LargeBinary data type Primary key can't be text Nov 20, 2018
@tulir
Copy link
Owner

tulir commented Nov 25, 2018

Thanks for the pull request!

I don't think the field can be made non-primary safely as the other fields don't uniquely identify files, but it can probably be a smaller column type since it's just a md5 hash. Maybe use BLOB on SQLite and BINARY(32) on other DBMSes or even just a LargeBinary(32)? Another option is to just drop the primary key completely

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants