Closed
Description
Describe the bug
MySQL error with the code 1366 and 1367 are mapped to InternalError instead of DataError
To Reproduce
For example try to pass string for the column which should be INTEGER, then you'll receive:
pymysql.err.InternalError: (1366, "Incorrect integer value: 'bad_value' for column 'col_int' at row 1")
Both MySQL errors defined in the ER.py
:
TRUNCATED_WRONG_VALUE_FOR_FIELD = 1366
ILLEGAL_VALUE_FOR_TYPE = 1367
are not explicitly mapped to the DataError in err.py
thus the InternalError is raised by default.
Schema:
CREATE DATABASE ...
CREATE TABLE ...
Code:
import pymysql
con = pymysql.connect(...)
Expected behavior
Expect to be raised DataError for data not conformant with the schema
Environment
- OS: Linux
- Server and version: MySQL 5.7.28
- PyMySQL version: 0.9.3
Additional context
Other cases like exceeding the number value for TINYINT or exceeding maximum allowed length for VARCHAR fields results in DataError
Metadata
Metadata
Assignees
Labels
No labels