diff options
Diffstat (limited to 'django/db/backends/mysql/base.py')
| -rw-r--r-- | django/db/backends/mysql/base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 9b88c5ac25..792eae086f 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -61,6 +61,7 @@ class CursorWrapper: codes_for_integrityerror = ( 1048, # Column cannot be null 1690, # BIGINT UNSIGNED value is out of range + 4025, # CHECK constraint failed ) def __init__(self, cursor): @@ -329,6 +330,15 @@ class DatabaseWrapper(BaseDatabaseWrapper): return True @cached_property + def data_type_check_constraints(self): + if self.features.supports_column_check_constraints: + return { + 'PositiveIntegerField': '`%(column)s` >= 0', + 'PositiveSmallIntegerField': '`%(column)s` >= 0', + } + return {} + + @cached_property def mysql_server_info(self): with self.temporary_connection() as cursor: cursor.execute('SELECT VERSION()') |
