MagicStack / MagicStack/asyncpg
BC dates result in error running the query
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
- asyncpg version: asyncpg=0.18.3=py37h1de35cc_0
- PostgreSQL version: PostgreSQL 11.1 on x86_64-apple-darwin18.2.0, compiled by Apple LLVM version 10.0.0 (clang-1000.11.45.5), 64-bit
- **Do you use a PostgreSQL SaaS? No
- Python version: 3.7
- Platform: osx
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: No
- Can the issue be reproduced under both asyncio and
uvloop?: Tried only asyncio
When a date or datetime column includes dates in the form of 0001-01-01 BC which are valid postgres dates, the driver returns the following:
result = await executor(stmt, None)
File "asyncpg/protocol/protocol.pyx", line 196, in bind_execute
File "asyncpg/protocol/coreproto.pyx", line 65, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
File "asyncpg/protocol/coreproto.pyx", line 202, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
File "asyncpg/protocol/coreproto.pyx", line 498, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
File "asyncpg/protocol/protocol.pyx", line 754, in asyncpg.protocol.protocol.BaseProtocol._decode_row
File "asyncpg/protocol/prepared_stmt.pyx", line 282, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
File "asyncpg/protocol/codecs/base.pyx", line 288, in asyncpg.protocol.protocol.Codec.decode
File "asyncpg/protocol/codecs/base.pyx", line 195, in asyncpg.protocol.protocol.Codec.decode_scalar
File "asyncpg/pgproto/./codecs/datetime.pyx", line 133, in asyncpg.pgproto.pgproto.date_decode
ValueError: ordinal must be >= 1
ValueError: ordinal must be >= 1
I assume this is some kind of a problem mapping from the BC date to a python date, however this is annoying since valid postgres tables can't be queries. At least in the interim it should be possible to return None if for some reason the date couldn't be parsed but not give up entirely. Is there a quick and dirty way around that?
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 asyncpg/pgproto/./codecs/datetime.pyx 中 traceback 所示的 date_decode 路径开始,使用包含 0001-01-01 BC 的 PostgreSQL date 或 datetime 重现该故障。检查现有的 date codec 测试,并确定 BC 值所支持的结果;完成标准是,解码此类行不再中止查询,并且该行为由回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100