[英]Loopback Mysql Connector: BIT(1) is recognized always true
I am using Loopback 3.22 with loopback-connector-mysql 5.3.1. 我正在使用Loopback 3.22和Loopback-connector-mysql 5.3.1。
When i configure loopback to covert BIT(1)
mysql column as boolean
it always returns true
当我将回送配置为隐式BIT(1)
mysql列为boolean
它总是返回true
"isActive": {
"type": "Boolean",
"required": false,
"length": null,
"precision": 1,
"scale": null,
"mysql": {
"columnName": "is_active",
"dataType": "bit",
"dataLength": null,
"dataPrecision": 1,
"dataScale": null,
"nullable": "Y"
}
},
I have wasted so much time here, I even tried to use before save
hooks, but column type validation kicks in before. 我在这里浪费了很多时间,甚至before save
钩子before save
尝试使用它,但是before save
列类型验证。
Making the column type Binary
pushes the problem to the frontend. 使列类型为Binary
将问题推送到前端。
这是LoopBack的MySQL连接器的已知错误,请参见以下GitHub问题: https : //github.com/strongloop/loopback-connector-mysql/issues/325
for anyone stuck here, I dirty patched MySQL.prototype.fromColumnValue
, in order to get this thing working until it gets fixed 对于卡在这里的任何人,我都对MySQL.prototype.fromColumnValue
肮脏的修补,以使该功能正常运行直至修复
let MySQL = require("loopback-connector-mysql/lib/mysql").MySQL;
...
case 'Boolean':
// extra case of Buffer(1)
if (val instanceof Buffer && val.length === 1) {
val = Boolean(val[0]);
} else {
// default case
val = Boolean(val);
}
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.