Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Won't Fix
-
1.1.13
-
None
-
WIN10, mariadb Server 10.6.11
-
3.9.13
Description
Summary
Both float and int values can be inserted in a mariadb column defined as DECIMAL. However, a mariadb.DataError is raised, when adding multiple rows with Cursor.executemany where some rows contain int and some contain float values for the same column. (Exception message is Invalid parameter type at row X, column Y
Steps to reproduce
- Setup server and database for testing
- Set environment variable TEST_DB_PASSWORD
- Add following test code (derived for test_conpy61 in testing/test/integration/test_cursor.py)
def test_conpyX(self):
with create_connection() as con:
cursor = con.cursor()
cursor.execute("CREATE TEMPORARY TABLE ind1 "
"(a decimal(8,4))")
Â
vals = [(1,), (2.3,)]
cursor.executemany("INSERT INTO ind1 VALUES (?)", vals)
del cursor
- In testing, run: python3 -m unittest test.integration.test_cursor -vv -k conpyX
Expectation
Test runs without errors.
Actual result
Exception
cursor.executemany("INSERT INTO ind1 VALUES (?)", vals)
|
mariadb.DataError: Invalid parameter type at row 2, column 1
|
Workaround
Convert all values to float before inserting