MagicStack / MagicStack/asyncpg
set_type_codec() doesn't work with copy_records_to_table()
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 8.1k
- Forks
- 469
- Merge moyen
- 18 min
- PR mergées (30 j)
- 4
Description
- asyncpg version: 0.23.0
- PostgreSQL version: 9.5.21
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: No and this is on a local PSQL install. - Python version: 3.6.13
- Platform: Ubuntu 16.04.6 LTS
- 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?: Not tried
The following:
await conn.set_type_codec(
"numeric",
encoder=str,
decoder=float,
schema="pg_catalog",
)
Doesn't work when used with copy_records_to_table()
...
File "asyncpg/protocol/protocol.pyx", line 504, in copy_in
File "asyncpg/protocol/protocol.pyx", line 437, in asyncpg.protocol.protocol.BaseProtocol.copy_in
asyncpg.exceptions._base.InternalClientError: no binary format encoder for type numeric (OID 1700)
This is despite solving issue https://github.com/MagicStack/asyncpg/issues/157 which added a binary format codec for numeric types - https://github.com/MagicStack/asyncpg/commit/0f8483517ebde66f3c7cc858fa6ad227c6e3fd64
Can we get the ability to provide a custom decoder without having to also provide an encoder then internally just fall back to the default encoder? I believe it should solve the issue. E.g.
await conn.set_type_codec(
"numeric",
decoder=float,
schema="pg_catalog",
)
or
await conn.set_type_codec(
"numeric",
encoder=None,
decoder=float,
schema="pg_catalog",
)
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez l’échec avec set_type_codec() et copy_records_to_table() en utilisant l’exemple numérique de l’issue. Commencez dans asyncpg/protocol/protocol.pyx, au niveau de copy_in et BaseProtocol.copy_in, puis suivez la manière dont le codec personnalisé est sélectionné. C’est terminé lorsqu’un décodeur personnalisé peut être utilisé tandis que copy_records_to_table() obtient toujours un encodeur pour numeric.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- postgresql, python
- Domaine
- databases
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100