Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
0.9.57
-
None
-
Archlinux 5.6.8-arch1-1 x86_64
Python 3.8.2
python-mariadb 0.9.57
Server version: 10.4.12-MariaDB Arch Linux
Description
Description:
When inserting multiple entries into a column that allows NULL values executemany() throws a DataError. This only happens if some of the tuples contain values with the coresponding type and some are of type None. If all values are None or if all values are not None and have the proper type, this error doesn't occur.
Steps to reproduce:
1. create a table with a column that allows NULL values
CREATE OR REPLACE TABLE `some_table` (`some_data` int(10) NULL); |
2. use executemany() to insert values that can either be of type int (in this example) or None
conn = mariadb.connect(**config) |
cur = conn.cursor() |
cur.executemany("INSERT INTO `some_table` (`some_data`) VALUES (?)", [(1,), (None,), (2,)]) |
conn.close()
|
Expected result:
Either a proper exception that describes why None cannot be inserted together with the proper type or insertion of NULL values.
Actual result:
A mariadb.DatabaseError.DataError with the message "Invalid parameter type at row 2, column 1".
(Another example can be found on StackOverflow)