diff options
author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-07-14 01:24:35 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-19 11:05:06 +0200 |
commit | 1fc2c70f7613e014a31771afa537439b28dd35fb (patch) | |
tree | dae8ebfe89e687edb518bd6031d89f9c47f774c9 /django/db/backends/mysql/base.py | |
parent | 7f612eda80db1c1c8e502aced54c2062080eae46 (diff) | |
download | django-1fc2c70f7613e014a31771afa537439b28dd35fb.tar.gz |
Fixed #30593 -- Added support for check constraints on MariaDB 10.2+.
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()') |