Open hordiienko-v opened 2 weeks ago
Thank you for the report. The solution is probably little enough invasive that we can provide it in the next bugfix release.
Psycopg 3 already does the right thing:
>>> import psycopg.sql
>>> from decimal import Decimal
>>> psycopg.sql.quote(Decimal("Infinity"))
"'Infinity'::numeric"
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.