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
failed to import schema with mysql utf8mb4 charset encoding. #6197
Comments
I've just noticed, my patch causes another problem
I need more digging :'( |
another dirty patch here: --- a/core/server/middleware/oauth.js
+++ b/core/server/middleware/oauth.js
@@ -13,7 +13,7 @@ function exchangeRefreshToken(client, refreshToken, scope, done) {
return done(new errors.NoPermissionError('Invalid refresh token.'), false);
} else {
var token = model.toJSON(),
- accessToken = utils.uid(256),
+ accessToken = utils.uid(191),
accessExpires = Date.now() + utils.ONE_HOUR_MS,
refreshExpires = Date.now() + utils.ONE_WEEK_MS;
@@ -46,8 +46,8 @@ function exchangePassword(client, username, password, scope, done) {
// Validate the user
return models.User.check({email: username, password: password}).then(function then(user) {
// Everything validated, return the access- and refreshtoken
- var accessToken = utils.uid(256),
- refreshToken = utils.uid(256),
+ var accessToken = utils.uid(191),
+ refreshToken = utils.uid(191),
accessExpires = Date.now() + utils.ONE_HOUR_MS,
refreshExpires = Date.now() + utils.ONE_WEEK_MS; I guess, we need more elegant patch to close this issue. |
Seems the best way to go about this would be to leave the field lengths as-is but set the index length to something smaller (since this only appears to be an issue with the unique index on those few fields). Surely the first 191 (or even 150) characters of the tokens and email address would be unique even if the value is longer. The only problem is that I don't see where knex has the ability to specify an index length of anything other than the field max length. |
Knex does not currently provide us with a way to change field lengths (see #4134). Given the existing outstanding issues with utf-8 (see #5945) and the fact that this is pretty edge-case I think it's unlikely that this is going to get fixed in the near future. I'd love to see someone work on providing a way to change field lengths in knex so that we can start work on things like this. |
✨ use utf8mb4 encoding closes TryGhost#5519, closes TryGhost#6197 - default encoding is utf8mb4 instead of utf8 - support emojis - read here why: http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html - read here why: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-conversion.html
closes TryGhost#5519, closes TryGhost#6197 - default encoding is utf8mb4 instead of utf8 - support emojis - read here why: http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html - read here why: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-conversion.html
💯 great! |
closes TryGhost#5519, closes TryGhost#6197 - default encoding is utf8mb4 instead of utf8 - support emojis - read here why: http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html - read here why: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-conversion.html
closes TryGhost#5519, closes TryGhost#6197 - default encoding is utf8mb4 instead of utf8 - support emojis - read here why: http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html - read here why: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-conversion.html
it looks like
email
column ofusers
table andtoken
column ofaccesstokens
andrefreshtokens
table.by the MySQL official document, indexed varchar should be 191 or smaller number of characters.
see also: http://stackoverflow.com/questions/20123824/how-can-i-alter-an-indexed-varchar255-from-utf8-to-utf8mb4-and-still-stay-unde
this is a simple patch:
FYI, full debug logs here:
The text was updated successfully, but these errors were encountered: