aio-libs / aio-libs/aiopg

SAConnection twophase methods are broken

Abierto
#886 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
1.4k
Forks
170
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Describe the bug

1. begin_twophase() is not a context manager
2. recover_twophase() is broken
3. rollback_prepared() is broken

### To Reproduce

just use these methods)

### Expected behavior

1. begin_twophase() behaves as a context manager, using commit_prepared() at the end OR docs changed to reflect current implementation
2. does not crash on accessing ResultProxy
3. does not crash on string formatting

### Logs/tracebacks

#### 1. begin_context() is not a context

According to docs: https://aiopg.readthedocs.io/en/stable/sa.html#aiopg.sa.SAConnection.begin_twophase

> coroutine async-with begin_twophase(xid=None)

but in reality:

```python-traceback
async with conn.begin_twophase() as transaction:
AttributeError: __aenter__
```

#### 2. recover_twophase() is broken

result is not awaited:

```python-traceback
File "/Users/ovmikhaylov/work/aiopg/aiopg/sa/connection.py", line 363, in recover_twophase
return [row[0] for row in result]
TypeError: 'ResultProxy' object is not iterable
```

#### 3. rollback_prepared() is broken

Due to error in f-string:

```python-traceback
File "/Users/ovmikhaylov/work/aiopg/aiopg/sa/connection.py", line 368, in rollback_prepared
await self.execute(f"ROLLBACK PREPARED {xid:!r}")
ValueError: Invalid format specifier
```

### Python Version

```console
3.10
```

### aiopg Version

```console
1.3.3
```

### OS

Darwin gmbp.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 x86_64

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow the aio-libs Code of Conduct

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.