You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
fromdecimalimportDecimalfrompsycopg2importconnectfrompsycopg2._psycopgimportconnection, cursorif__name__=="__main__":
conn: connectioncurr: cursorwithconnect("dbname=test_db user=test_user password=test_user") asconn:
withconn.cursor() ascurr:
q=curr.mogrify(
"INSERT INTO test VALUES (%s), (%s)",
[Decimal("1"), Decimal("Infinity")],
)
print(q)
# b"INSERT INTO test VALUES (1), ('NaN'::numeric)"
The text was updated successfully, but these errors were encountered:
Since v14, PostgreSQL NUMERIC type supports
Infinity
value. But for now, psycopg2 adaptsInfinity
as'NaN'::numeric
. This can be avoided by creating custom type adapter that wraps decimal value in quotes, but still, adapting toNaN
seems like outdated logic.The text was updated successfully, but these errors were encountered: