mirror of
https://github.com/django/django.git
synced 2025-06-03 10:39:12 +00:00
Fixed #7628 -- Oracle backend won't try to recreate existing sequences during syncdb. Thanks, cmarshal.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8522 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fbf09ee11d
commit
6b5a607606
@ -26,12 +26,14 @@ from django.utils.encoding import smart_str, force_unicode
|
|||||||
DatabaseError = Database.Error
|
DatabaseError = Database.Error
|
||||||
IntegrityError = Database.IntegrityError
|
IntegrityError = Database.IntegrityError
|
||||||
|
|
||||||
|
|
||||||
class DatabaseFeatures(BaseDatabaseFeatures):
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
empty_fetchmany_value = ()
|
empty_fetchmany_value = ()
|
||||||
needs_datetime_string_cast = False
|
needs_datetime_string_cast = False
|
||||||
uses_custom_query_class = True
|
uses_custom_query_class = True
|
||||||
interprets_empty_strings_as_nulls = True
|
interprets_empty_strings_as_nulls = True
|
||||||
|
|
||||||
|
|
||||||
class DatabaseOperations(BaseDatabaseOperations):
|
class DatabaseOperations(BaseDatabaseOperations):
|
||||||
def autoinc_sql(self, table, column):
|
def autoinc_sql(self, table, column):
|
||||||
# To simulate auto-incrementing primary keys in Oracle, we have to
|
# To simulate auto-incrementing primary keys in Oracle, we have to
|
||||||
@ -40,7 +42,17 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||||||
tr_name = get_trigger_name(table)
|
tr_name = get_trigger_name(table)
|
||||||
tbl_name = self.quote_name(table)
|
tbl_name = self.quote_name(table)
|
||||||
col_name = self.quote_name(column)
|
col_name = self.quote_name(column)
|
||||||
sequence_sql = 'CREATE SEQUENCE %s;' % sq_name
|
sequence_sql = """
|
||||||
|
DECLARE
|
||||||
|
i INTEGER;
|
||||||
|
BEGIN
|
||||||
|
SELECT COUNT(*) INTO i FROM USER_CATALOG
|
||||||
|
WHERE TABLE_NAME = '%(sq_name)s' AND TABLE_TYPE = 'SEQUENCE';
|
||||||
|
IF i = 0 THEN
|
||||||
|
EXECUTE IMMEDIATE 'CREATE SEQUENCE %(sq_name)s';
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
/""" % locals()
|
||||||
trigger_sql = """
|
trigger_sql = """
|
||||||
CREATE OR REPLACE TRIGGER %(tr_name)s
|
CREATE OR REPLACE TRIGGER %(tr_name)s
|
||||||
BEFORE INSERT ON %(tbl_name)s
|
BEFORE INSERT ON %(tbl_name)s
|
||||||
@ -195,7 +207,7 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||||||
|
|
||||||
|
|
||||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
|
|
||||||
operators = {
|
operators = {
|
||||||
'exact': '= %s',
|
'exact': '= %s',
|
||||||
'iexact': '= UPPER(%s)',
|
'iexact': '= UPPER(%s)',
|
||||||
@ -212,7 +224,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
}
|
}
|
||||||
oracle_version = None
|
oracle_version = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DatabaseWrapper, self).__init__(*args, **kwargs)
|
super(DatabaseWrapper, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.features = DatabaseFeatures()
|
self.features = DatabaseFeatures()
|
||||||
@ -265,6 +277,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
cursor.arraysize = 100
|
cursor.arraysize = 100
|
||||||
return cursor
|
return cursor
|
||||||
|
|
||||||
|
|
||||||
class OracleParam(object):
|
class OracleParam(object):
|
||||||
"""
|
"""
|
||||||
Wrapper object for formatting parameters for Oracle. If the string
|
Wrapper object for formatting parameters for Oracle. If the string
|
||||||
@ -285,6 +298,7 @@ class OracleParam(object):
|
|||||||
else:
|
else:
|
||||||
self.input_size = None
|
self.input_size = None
|
||||||
|
|
||||||
|
|
||||||
class FormatStylePlaceholderCursor(Database.Cursor):
|
class FormatStylePlaceholderCursor(Database.Cursor):
|
||||||
"""
|
"""
|
||||||
Django uses "format" (e.g. '%s') style placeholders, but Oracle uses ":var"
|
Django uses "format" (e.g. '%s') style placeholders, but Oracle uses ":var"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user