You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
D:\personal\youkey-bot\node_modules\mysql\lib\protocol\Parser.js:437
throw err; // Rethrow non-MySQL errors
^
SyntaxError: Unexpected end of JSON input
at PoolConnection.typeCast (D:\personal\youkey-bot\node_modules\koishi-plugin-mysql\lib\index.js:143:28)
at RowDataPacket.parse (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\packets\RowDataPacket.js:33:24)
at Query.RowDataPacket (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\sequences\Query.js:153:10)
at Protocol._parsePacket (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\Protocol.js:260:14)
at Parser._parsePacket (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (D:\personal\youkey-bot\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (D:\personal\youkey-bot\node_modules\mysql\lib\Connection.js:88:28)
at Socket.<anonymous> (D:\personal\youkey-bot\node_modules\mysql\lib\Connection.js:526:10)
Steps to reproduce
矛头都指向这里
typeCast: (field, next) => {
const { orgName, orgTable } = field.packet
const type = MysqlDatabase.tables[orgTable]?.[orgName]
if (typeof type === 'object') return type.parse(field)
const meta = Koishi.Tables.config[orgTable]?.fields[orgName]
if (meta?.type === 'string') {
return field.string()
} else if (meta?.type === 'json') {
return JSON.parse(field.string()) || meta.initial
} else if (meta?.type === 'list') {
const source = field.string()
return source ? source.split(',') : []
}
if (field.type === 'BIT') {
return Boolean(field.buffer()?.readUInt8(0))
} else {
return next()
}
},
Describe the bug
使用这个
还是这个
都出现以下错误:
Steps to reproduce
矛头都指向这里
Expected behavior
我改了以下代码:
return JSON.parse(field.string()) || meta.initial
变
return meta.initial || JSON.parse(field.string())
最后数据库都没有默认值
Screenshots
No response
Versions
Additional context
No response
The text was updated successfully, but these errors were encountered: