We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL查询中,decimal超过16位,会自动四舍五入 例如我的数据类型是decimal,真实数据是173000003740634298,archery查询返回173000003740634300
CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, phone varchar(13) DEFAULT NULL, curdate datetime DEFAULT NULL, pid decimal(18,0) DEFAULT NULL, pid1 bigint DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8
t1
id
phone
curdate
pid
pid1
mysql> select * from t1; +----+--------------+---------------------+--------------------+--------------------+ | id | phone | curdate | pid | pid2 | +----+--------------+---------------------+--------------------+--------------------+ | 1 | 18611130824 | NULL | 173000003740634298 | 173000003740634298 | ..... | 19 | 186111130824 | 2021-12-07 22:52:27 | 173000003740634298 | 173000003740634298 | +----+--------------+---------------------+--------------------+--------------------+ 17 rows in set (0.00 sec)`
archery 查询返回: 捕获日志:
可以看到, 真实数据返回,pid字段返回decimal,序列化之后返回int 而pid2字段返回int,序列化之后返回str 原因是js遇到2**53也就是超过16位时候会自动四舍五入,原始代码只对int做了str处理,没有对decimal处理,原始代码:sql/query.py return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True),
return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True),
加入对decimal处理,如下解决: return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True, use_decimal=False),
return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True, use_decimal=False),
The text was updated successfully, but these errors were encountered:
你好,代码方便提一个pr吗
Sorry, something went wrong.
#1250
作者已经在v1.8.2修复。
No branches or pull requests
bug描述
SQL查询中,decimal超过16位,会自动四舍五入
例如我的数据类型是decimal,真实数据是173000003740634298,archery查询返回173000003740634300
bug复现
CREATE TABLE
t1
(id
int(11) NOT NULL AUTO_INCREMENT,phone
varchar(13) DEFAULT NULL,curdate
datetime DEFAULT NULL,pid
decimal(18,0) DEFAULT NULL,pid1
bigint DEFAULT NULL,PRIMARY KEY (
id
)) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8
mysql> select * from t1;
+----+--------------+---------------------+--------------------+--------------------+
| id | phone | curdate | pid | pid2 |
+----+--------------+---------------------+--------------------+--------------------+
| 1 | 18611130824 | NULL | 173000003740634298 | 173000003740634298 |
.....
| 19 | 186111130824 | 2021-12-07 22:52:27 | 173000003740634298 | 173000003740634298 |
+----+--------------+---------------------+--------------------+--------------------+
17 rows in set (0.00 sec)`
archery 查询返回:
![image](https://user-images.githubusercontent.com/43569914/147680938-882925c4-d45a-4e0d-b072-c758d29ec866.png)
![image](https://user-images.githubusercontent.com/43569914/147680975-024e8620-0a59-48df-9014-6fd743a73c18.png)
捕获日志:
问题分析
可以看到,
真实数据返回,pid字段返回decimal,序列化之后返回int
而pid2字段返回int,序列化之后返回str
原因是js遇到2**53也就是超过16位时候会自动四舍五入,原始代码只对int做了str处理,没有对decimal处理,原始代码:sql/query.py
return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True),
解决方案
加入对decimal处理,如下解决:
return HttpResponse(json.dumps(result, cls=ExtendJSONEncoderFTime, bigint_as_string=True, use_decimal=False),
The text was updated successfully, but these errors were encountered: