diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 6bf2e815a7..f4b11ec327 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -51,6 +51,7 @@ from django.db.backends.signals import connection_created from django.db.backends.oracle.client import DatabaseClient from django.db.backends.oracle.creation import DatabaseCreation from django.db.backends.oracle.introspection import DatabaseIntrospection +from django.db.backends.oracle.schema import DatabaseSchemaEditor from django.utils.encoding import force_bytes, force_text from django.utils import six from django.utils import timezone @@ -571,6 +572,10 @@ class DatabaseWrapper(BaseDatabaseWrapper): and x.code == 2091 and 'ORA-02291' in x.message: six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2]) six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2]) + + def schema_editor(self): + "Returns a new instance of this backend's SchemaEditor" + return DatabaseSchemaEditor(self) class OracleParam(object): diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index d9bf3dfea2..c4dc80503c 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -17,7 +17,7 @@ class DatabaseCreation(BaseDatabaseCreation): data_types = { 'AutoField': 'NUMBER(11)', - 'BooleanField': 'NUMBER(1) CHECK (%(qn_column)s IN (0,1))', + 'BooleanField': 'NUMBER(1)', 'CharField': 'NVARCHAR2(%(max_length)s)', 'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)', 'DateField': 'DATE', @@ -30,10 +30,10 @@ class DatabaseCreation(BaseDatabaseCreation): 'BigIntegerField': 'NUMBER(19)', 'IPAddressField': 'VARCHAR2(15)', 'GenericIPAddressField': 'VARCHAR2(39)', - 'NullBooleanField': 'NUMBER(1) CHECK ((%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL))', + 'NullBooleanField': 'NUMBER(1)', 'OneToOneField': 'NUMBER(11)', - 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', - 'PositiveSmallIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 0)', + 'PositiveIntegerField': 'NUMBER(11)', + 'PositiveSmallIntegerField': 'NUMBER(11)', 'SlugField': 'NVARCHAR2(%(max_length)s)', 'SmallIntegerField': 'NUMBER(11)', 'TextField': 'NCLOB', @@ -41,6 +41,13 @@ class DatabaseCreation(BaseDatabaseCreation): 'URLField': 'VARCHAR2(%(max_length)s)', } + data_type_check_constraints = { + 'BooleanField': '%(qn_column)s IN (0,1)', + 'NullBooleanField': '(%(qn_column)s IN (0,1)) OR (%(qn_column)s IS NULL)', + 'PositiveIntegerField': '"%(qn_column)s" >= 0', + 'PositiveSmallIntegerField': '"%(qn_column)s" >= 0', + } + def __init__(self, connection): super(DatabaseCreation, self).__init__(connection)