Skip to content

Invalid error mapping to InternalError instead of DataError #851

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

Closed
pgs-fhonckiewicz opened this issue Mar 27, 2020 · 0 comments · Fixed by #873
Closed

Invalid error mapping to InternalError instead of DataError #851

pgs-fhonckiewicz opened this issue Mar 27, 2020 · 0 comments · Fixed by #873

Comments

@pgs-fhonckiewicz
Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant