gpt4 book ai didi

sails.js - 带有 sails-mysql 的 SailsJS 1.0 中的 ER_TOO_LONG_KEY

转载 作者:行者123 更新时间:2023-12-02 01:13:14 24 4
gpt4 key购买 nike

当我尝试sails lift 时我遇到了这个错误:

info: ·• Auto-migrating...  (drop)
error: A hook (`orm`) failed to load!
error:
error: Error: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes

我现在只有一个模型:

module.exports = {

datastore: 'default',
tableName: 'sci_user',
attributes: {
email: {
type: 'string',
required: true,
unique: true
},
password: {
type: 'string',
required: true
}
}

它真的很简单,我是从文档中得到的。我不明白。这似乎是因为 unique: true

最佳答案

这是多种因素综合造成的,但最相关的是 sails-mysql 目前默认使用 utf8mb4 字符集作为字符串属性,以允许使用表情符号和其他扩展字符。我们正在开发一个补丁,使它成为可配置的而不是默认的,但与此同时,最快的解决方法是直接为您的属性声明 columnType:

module.exports = {

datastore: 'default',
tableName: 'sci_user',
attributes: {
email: {
type: 'string',
required: true,
unique: true,
columnType: 'varchar'
},
password: {
type: 'string',
required: true,
columnType: 'varchar'
}
}

关于sails.js - 带有 sails-mysql 的 SailsJS 1.0 中的 ER_TOO_LONG_KEY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43984693/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com