MagicStack / MagicStack/asyncpg

Prepared_stmt.fetch() should explicitly either return None or an empty list

未关闭
#459 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.1k
派生
468
PR 合并指标
30 天内没有已合并 PR

描述

  • asyncpg version: 0.18.3
  • PostgreSQL version: 11
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Install is local
  • Python version: 3.7.3
  • Platform: Windows 10
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?: N/A
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : Have not attempted at this time

This is a great help, thank you for this module!

Since the doc says fetch() returns a list of Records, I initially tried to use it to check if something exists in my database by checking it for a len() of 0. However, this produced unexpected results (but no clear error), so I went to check the documentation again.

While fetchval and fetchrow both explicitly return None if __bind_execute does not return any data, it's not made clear what will be returned if the data is not found in the general fetch() method. Protocol.bind_execute doesn't clearly state this either.

I think it would make most sense to return an empty list, but if it returns None instead that also makes sense with the result of that function 'family.' Either way it would be great to make this explicit in the method itself!

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Prepared_stmt.fetch() 开始,将其文档描述的行为与 fetchval() 和 fetchrow() 进行比较,issue 将后两者标识为明确的对应项。确认没有行时的结果,并明确 fetch() 的返回契约,包括它是 None 还是空列表;如果现有项目测试能够体现这一行为,则为该行为添加或更新覆盖率。

由索引模型根据 Issue 内容生成。

评估

技术栈
postgresql, python
领域
database
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。