MagicStack / MagicStack/asyncpg

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

Abierto
#459 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
8.1k
Forks
468
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

* **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!

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza en Prepared_stmt.fetch() y compara su comportamiento documentado con fetchval() y fetchrow(), que el issue identifica como contrapartes explícitas. Confirma el resultado cuando no hay filas y haz explícito el contrato de retorno de fetch(), incluido si es None o una lista vacía; añade o actualiza la cobertura de ese comportamiento si las pruebas existentes del proyecto lo ponen de manifiesto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
postgresql, python
Área
database
Tipo de issue
Documentación
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.