MagicStack / MagicStack/asyncpg
Prepared_stmt.fetch() should explicitly either return None or an empty list
まだ誰も着手していません。
- 主要言語
- 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](https://github.com/magicstack/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!
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Prepared_stmt.fetch() から始め、Issue が明示的な対応物として挙げている fetchval() および fetchrow() と、その文書化された動作を比較します。行がない場合の結果を確認し、None なのか空のリストなのかも含めて、fetch() の戻り値の契約を明確にします。既存のプロジェクトテストでその動作が明らかになる場合は、その動作に対するカバレッジを追加または更新します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- postgresql, python
- 領域
- database
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100