MagicStack / MagicStack/asyncpg
Nested custom types in Postgres break `asyncpg.Record` subclassing
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 468
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
* **asyncpg version**: v0.25.0
* **PostgreSQL version**: 14
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: on-premise
* **Python version**: 3.10.1
* **Platform**: linux
* **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)?**: n/a
It would appear that nested types are not converted to a user specified `record_class`, and instead will always use `asyncpg.Record`.
For example:
```
CREATE TYPE my_custom_type AS (
id int,
filename text,
sql text
);
CREATE TABLE my_table (
files my_custom_type[] NOT NULL,
);
SELECT * FROM my_table
```
If you specify a custom `record_class`, then the record from `SELECT * FROM my_table` will be your subclass. However, the value inside `record['files']` will use the `asyncpg.Record` class, rather than the custom one specified.
## What should actually happen?
I think if a user specifies a `record_class`, then this class should always be used, even for nested custom types. It's quite unexpected behaviour for `asyncpg` to use the default class when a custom one has been specified.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il problema con il tipo PostgreSQL personalizzato, la colonna array, la query SELECT e una record_class personalizzata descritti nel report. Traccia il modo in cui vengono decodificati i valori di tipo personalizzato annidati e come viene propagata record_class; il lavoro è completo quando i record all'interno di record['files'] usano la sottoclasse specificata invece di asyncpg.Record, con una copertura di regressione per questo caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100