Nikolay Zakharov  committed 29c5aac

Oracle: fix ImportError (get_sequence_name)

  • Participants
  • Parent commits 2ffeac0
  • Branches default

Comments (0)

Files changed (1)

File south/db/

 from django.db import connection, models
 from django.db.backends.util import truncate_name
 from import no_style
-from import get_sequence_name
 from django.db.models.fields import NOT_PROVIDED
 from django.db.utils import DatabaseError
+# In revision r16016 function get_sequence_name has been transformed into
+# method of DatabaseOperations class. To make code backward-compatible we
+# need to handle both situations.
+    from import get_sequence_name\
+        as original_get_sequence_name
+except ImportError:
+    original_get_sequence_name = None
 from south.db import generic
 print >> sys.stderr, " ! WARNING: South's Oracle support is still alpha."
         'R': 'FOREIGN KEY'
+    def get_sequence_name(self, table_name):
+        if original_get_sequence_name is None:
+            return self._get_connection().ops._get_sequence_name(table_name)
+        else:
+            return original_get_sequence_name(table_name)
     def adj_column_sql(self, col):
         col = re.sub('(?P<constr>CHECK \(.*\))(?P<any>.*)(?P<default>DEFAULT \d+)', 
                      lambda mo: '%s %s%s'%('default'),'constr'),'any')), col) #syntax fix for boolean/integer field only
         EXECUTE IMMEDIATE 'DROP SEQUENCE "%(sq_name)s"';
     END IF;
-/""" % {'sq_name': get_sequence_name(table_name)}
+/""" % {'sq_name': self.get_sequence_name(table_name)}