int改不了mysql_res 返回不了,MySQL返回不正确的bigint结果,一个很奇怪的错误

I really don't know what is going on here. I have a database table that looks like this:

4bfcda5b93efe42e74822b161d8b1328.png

With this data:

2fdfb8bded85a5c4309c690346af5f71.png

When I run this query SELECT * FROM game WHERE id = 4 in phpmyadmin I get back this result as expected:

673ed9e3a26d18daf64095d9feae3a54.png

But when I make this query on it through a rest api (where gameId = 4)

var query = connection.query("SELECT * FROM game WHERE id = ? ",[game.gameId],function(err,rows){

I get this result

62b8a6cbef8b2becf26f4bba027798a0.png

Where adminId for some reason has been subtracted by one. I really haven't a clue what is going on. I have tried dropping the table and setting it back up, has anyone experienced this before? Or know what is wrong? It's pretty frustrating! Thanks

解决方案

The maximum integer JavaScript can safely represent is Number.MAX_SAFE_INTEGER, which is 2^53 - 1. Your value is greater than that, which is causing some bits to be lost.

node-mysql has supportBigNumbers and bigNumberStrings options that parse BIGINTs as strings.

var connection = mysql.createConnection({

supportBigNumbers: true,

bigNumberStrings: true

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值