MagicStack / MagicStack/asyncpg
bug: Incorrect serialization of numeric values
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: 0.29.0
- PostgreSQL version: 13
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: no SaaS, yes reproducable with local postgres - Python version: 3.10
- 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?: none
- Can the issue be reproduced under both asyncio and
uvloop?: yes
This happens when query selects a numeric column. Numbers like 10000, 100000, etc. get serialized in scientific notation. For example 10000 becomes 1E+4.
To reproduce the error, you can do the following:
Inside tests/test_codecs/test_numeric if 10000 is added in cases then the test fails, due to incorrect serialization logic.
async def test_numeric(self):
# Test that we handle dscale correctly.
cases = [
'0.001',
'0.001000',
'1',
'1.00000',
'10000', # new test case
]
fail error:
line 614, in test_numeric
self.assertEqual(str(res), case)
AssertionError: '1E+4' != '10000'
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 in tests/test_codecs/test_numeric e aggiungi 10000 ai casi in test_numeric per riprodurre il fallimento. Traccia la logica di serializzazione numerica responsabile della restituzione di 1E+4 invece di 10000, quindi esegui il test e conferma che i casi esistenti continuino a superare il test mantenendo la stringa decimale prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100