Skip to content

Check decimal.Decimal("NaN"|"sNaN"|"Infinity"|"-Infinity") parameter. #1209

@9EOR9

Description

@9EOR9

Describe the bug

While PyMySQL handles float("nan"|"inf"|"-inf") correctly and raises an exception before sending the command to the server, it doesn't handle corresponding decimal.Decimal types (NaN, sNaN, Infinity, -Infinity).

To Reproduce

Code:

import pymysql
con = pymysql.connect(...)
cursor = con.cursor()

a= float("nan")
b= decimal.Decimal("nan")
try:
    cursor.execute("select %s", (a,))
 except Exception as e:
     print(e)
     pass
     
try:
     cursor.execute("select %s", (b,))
except Exception as e:
     print(e)
     pass

Expected behavior

nan can not be used with MySQL
nan can not be used with MySQL

Preferrable in both cases the exception should be a NotSupportedError with the following message:
Parameter 'nan' for float or decimal types is not supported

Environment

  • PyMySQL version: 1.4.5

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions