Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Very initial Oracle support

  • Loading branch information...
commit 8413c85f3d9a5d7f0485e621ec5836484c974f30 1 parent 828d691
Andrew Godwin andrewgodwin authored
5 django/db/backends/oracle/base.py
View
@@ -51,6 +51,7 @@ def _setup_environment(environ):
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 @@ def _commit(self):
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):
15 django/db/backends/oracle/creation.py
View
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.