-
-
Notifications
You must be signed in to change notification settings - Fork 524
Closed
Description
- OS: Ubuntu
- Psycopg version: 2.9.9
- Python version: 3.9
- PostgreSQL version: 16.2
- pip version: 21.2.4
Since v14, PostgreSQL NUMERIC type supports Infinity value. But for now, psycopg2 adapts Infinity as 'NaN'::numeric. This can be avoided by creating custom type adapter that wraps decimal value in quotes, but still, adapting to NaN seems like outdated logic.
from decimal import Decimal
from psycopg2 import connect
from psycopg2._psycopg import connection, cursor
if __name__ == "__main__":
conn: connection
curr: cursor
with connect("dbname=test_db user=test_user password=test_user") as conn:
with conn.cursor() as curr:
q = curr.mogrify(
"INSERT INTO test VALUES (%s), (%s)",
[Decimal("1"), Decimal("Infinity")],
)
print(q)
# b"INSERT INTO test VALUES (1), ('NaN'::numeric)"Metadata
Metadata
Assignees
Labels
No labels