MySQL返回不正确的bigint结果,一个很奇怪的错误 [英] Mysql returning incorrect bigint result by one, very strange error
问题描述
我真的不知道这是怎么回事.我有一个数据库表,看起来像这样:
I really don't know what is going on here. I have a database table that looks like this:
使用此数据:
当我在phpmyadmin中运行此查询SELECT * FROM game WHERE id = 4
时,我按预期返回了此结果:
When I run this query SELECT * FROM game WHERE id = 4
in phpmyadmin I get back this result as expected:
但是当我通过rest api(其中gameId = 4)对其进行查询时
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){
我得到这个结果
由于某种原因将adminId减一的地方.我真的不知道发生了什么.我已经尝试过放下桌子并将其设置为备份状态,有人以前经历过吗?还是知道出什么问题了?真令人沮丧!谢谢
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具有supportBigNumbers
和bigNumberStrings
选项,可将BIGINT
解析为字符串.
node-mysql has supportBigNumbers
and bigNumberStrings
options that parse BIGINT
s as strings.
var connection = mysql.createConnection({
supportBigNumbers: true,
bigNumberStrings: true
});
这篇关于MySQL返回不正确的bigint结果,一个很奇怪的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!