MagicStack / MagicStack/asyncpg
bug: Incorrect serialization of numeric values
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
* **asyncpg version**: 0.29.0
* **PostgreSQL version**: 13
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: no SaaS, yes reproducable with local postgres
* **Python version**: 3.10
* **Platform**: linux
* **Do you use pgbouncer?**: no
* **Did you install asyncpg with pip?**: yes
* **If you built asyncpg locally, which version of Cython did you use?**: none
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: yes
This happens when query selects a numeric column. Numbers like 10000, 100000, etc. get serialized in scientific notation. For example 10000 becomes 1E+4.
To reproduce the error, you can do the following:
Inside `tests/test_codecs/test_numeric` if `10000` is added in `cases` then the test fails, due to incorrect serialization logic.
```
async def test_numeric(self):
# Test that we handle dscale correctly.
cases = [
'0.001',
'0.001000',
'1',
'1.00000',
'10000', # new test case
]
```
fail error:
```
line 614, in test_numeric
self.assertEqual(str(res), case)
AssertionError: '1E+4' != '10000'
```
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 tests/test_codecs/test_numeric 开始,在 test_numeric 的用例中添加 10000 以复现该失败。跟踪负责返回 1E+4 而不是 10000 的数字序列化逻辑,然后运行测试并确认现有用例仍能通过,同时保留预期的小数字符串。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100