Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The table definition for the session backend doesn't work for MySQL #10

Open
sbditto85 opened this issue Jan 23, 2017 · 1 comment
Open

Comments

@sbditto85
Copy link
Contributor

When using MySQL as a session backend the SQL generated for creating the table looks like:

CREATe TABLE `persistent_session`( PRIMARY KEY (`key`),`key` TEXT CHARACTER SET utf8 NOT NULL,`auth_id` BLOB NULL,`session` BLOB NOT NULL,`created_at` DATETIME NOT NULL,`accessed_at` DATETIME NOT NULL)

however when that is ran it gets a error:

*** Exception: ConnectionError {errFunction = "query", errNumber = 1170, errMessage = "BLOB/TEXT column 'key' used in key specification without a key length"}

Error 1170 says:

MySQL Error 1170 (42000): BLOB/TEXT Column Used in Key Specification Without a Key Length. The error happens because MySQL can index only the first N chars of a BLOB or TEXT column.

So to have a text value as a key you would need it to be bound in some way. When researching most people said to instead use a varchar(###) to get similar results as text, but with the proper limiting for the index. I have manually created a table using varchar(255) as an experiment and it works fine. Though now if i run the migrations it crashes as it tries to alter the table back to an unbounded text column.

I've attempted to look at the code to see how to fix it, but I'm not experienced with persistent's inner working and have no idea what the best course of action would be to use MySQL as a session backend.

Thanks

@sbditto85
Copy link
Contributor Author

annnddd as soon as i posted this i figured out a way to fix it. Typical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant