MagicStack / MagicStack/asyncpg
Prepared_stmt.fetch() should explicitly either return None or an empty list
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 8.1k
- Forks
- 468
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
- 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!
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei Prepared_stmt.fetch() und vergleiche dessen dokumentiertes Verhalten mit fetchval() und fetchrow(), die das Issue als explizite Gegenstücke bezeichnet. Bestätige das Ergebnis bei keiner Zeile und mache den Rückgabevertrag von fetch() explizit, einschließlich der Frage, ob es None oder eine leere Liste ist; füge Tests für dieses Verhalten hinzu oder aktualisiere die Abdeckung dafür, falls die bestehenden Projekttests es erkennen lassen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- postgresql, python
- Bereich
- database
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100