Loading django/db/backends/__init__.py +3 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,9 @@ class BaseDatabaseFeatures(object): # Does it support foreign keys? supports_foreign_keys = True # Does it support CHECK constraints? supports_check_constraints = True def __init__(self, connection): self.connection = connection Loading django/db/backends/creation.py +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ class BaseDatabaseCreation(object): destruction of test databases. """ data_types = {} data_type_check_constraints = {} def __init__(self, connection): self.connection = connection Loading django/db/backends/mysql/base.py +1 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): requires_explicit_null_ordering_when_grouping = True allows_primary_key_0 = False uses_savepoints = True supports_check_constraints = False def __init__(self, connection): super(DatabaseFeatures, self).__init__(connection) Loading django/db/backends/postgresql_psycopg2/creation.py +7 −2 Original line number Diff line number Diff line Loading @@ -26,14 +26,19 @@ class DatabaseCreation(BaseDatabaseCreation): 'GenericIPAddressField': 'inet', 'NullBooleanField': 'boolean', 'OneToOneField': 'integer', 'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)', 'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)', 'PositiveIntegerField': 'integer', 'PositiveSmallIntegerField': 'smallint', 'SlugField': 'varchar(%(max_length)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', } data_type_check_constraints = { 'PositiveIntegerField': '"%(column)s" >= 0', 'PositiveSmallIntegerField': '"%(column)s" >= 0', } def sql_table_creation_suffix(self): assert self.connection.settings_dict['TEST_COLLATION'] is None, "PostgreSQL does not support collation setting at database creation time." if self.connection.settings_dict['TEST_CHARSET']: Loading django/db/backends/postgresql_psycopg2/introspection.py +1 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): kc.table_schema = %s AND kc.table_name = %s """, ["public", table_name]) for constraint, column, kind in cursor.fetchall(): for constraint, column in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { Loading Loading
django/db/backends/__init__.py +3 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,9 @@ class BaseDatabaseFeatures(object): # Does it support foreign keys? supports_foreign_keys = True # Does it support CHECK constraints? supports_check_constraints = True def __init__(self, connection): self.connection = connection Loading
django/db/backends/creation.py +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ class BaseDatabaseCreation(object): destruction of test databases. """ data_types = {} data_type_check_constraints = {} def __init__(self, connection): self.connection = connection Loading
django/db/backends/mysql/base.py +1 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): requires_explicit_null_ordering_when_grouping = True allows_primary_key_0 = False uses_savepoints = True supports_check_constraints = False def __init__(self, connection): super(DatabaseFeatures, self).__init__(connection) Loading
django/db/backends/postgresql_psycopg2/creation.py +7 −2 Original line number Diff line number Diff line Loading @@ -26,14 +26,19 @@ class DatabaseCreation(BaseDatabaseCreation): 'GenericIPAddressField': 'inet', 'NullBooleanField': 'boolean', 'OneToOneField': 'integer', 'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)', 'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)', 'PositiveIntegerField': 'integer', 'PositiveSmallIntegerField': 'smallint', 'SlugField': 'varchar(%(max_length)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', } data_type_check_constraints = { 'PositiveIntegerField': '"%(column)s" >= 0', 'PositiveSmallIntegerField': '"%(column)s" >= 0', } def sql_table_creation_suffix(self): assert self.connection.settings_dict['TEST_COLLATION'] is None, "PostgreSQL does not support collation setting at database creation time." if self.connection.settings_dict['TEST_CHARSET']: Loading
django/db/backends/postgresql_psycopg2/introspection.py +1 −1 Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): kc.table_schema = %s AND kc.table_name = %s """, ["public", table_name]) for constraint, column, kind in cursor.fetchall(): for constraint, column in cursor.fetchall(): # If we're the first column, make the record if constraint not in constraints: constraints[constraint] = { Loading