Conversion of float 'inf' to string fails after 1.3.14
zbentley opened this issue · comments
Zac Bentley commented
Read this first
Describe the bug
If I run cursor.execute("SELECT '%s' FROM dual", (float('inf'),)
, on 1.3.13 and earlier, I get (('inf',),)
back, as expected. On later versions, I get a ProgrammingError raised by this converter indicating that infinity is not allowed.
That change was introduced with good intentions, but I do not think it makes sense. It's reasonable to want to stringify inf/nan and store that representation in a string column. Using a custom converter should not be necessary.
To Reproduce
Code
con = MySQLdb.connect(...)
cur = con.cursor()
cur.execute("SELECT '%s' FROM dual", (float('inf'),)
Environment
MySQL Server
- Server OS: MacOS 12, Ubuntu 20
- Server Version: MySQL 5.7
MySQL Client
- OS MacOS 12
- Python Pyenv 3.7.13
- Connector/C Homebrew MySQL @5.7, linked.
Inada Naoki commented
str(float('inf'))
is enough.