Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
9EOR9 opened this issue May 9, 2025 · 0 comments
Open

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

9EOR9 opened this issue May 9, 2025 · 0 comments

Comments

@9EOR9
Copy link

9EOR9 commented May 9, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant