Description
- asyncpg version: 0.18.3
- PostgreSQL version: PostgreSQL 10.10 / PostgreSQL 11.5
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Yes, problem is reproduced using the PostgreSQL provided by AWS and a local install - Python version: 3.7
- Platform: Linux / Darwin 18.6.0 x86_64
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: No
- Can the issue be reproduced under both asyncio and
uvloop?: Yes
I have encountered that asyncpg decodes values of NUMERIC type with extra zero decimal digits despite the explicitly specified scale.
This code:
import asyncio
import asyncpg
async def main():
conn = await asyncpg.connect()
await conn.execute('''
CREATE TABLE test_numeric(
id serial PRIMARY KEY,
value NUMERIC(1000, 8)
)
''')
await conn.execute('''
INSERT INTO test_numeric(value) VALUES('0.00003000')
''')
row = await conn.fetchrow('SELECT * FROM test_numeric;')
print(row)
await conn.close()
asyncio.get_event_loop().run_until_complete(main())
Produces the following output (12 digits right to the point while the scale of 8 was specified):
<Record id=1 value=Decimal('0.000030000000')>
However, in the database everything looks fine:
test=# SELECT * FROM test_numeric;
id | value
----+------------
1 | 0.00003000
Metadata
Metadata
Assignees
Labels
No labels