Commits

Michael Manfre  committed 0c22c23

Fixed TEST_CREATE with _destroy_test_db. It'll now actually skip the destruction, instead of saying it will and proceeding.

  • Participants
  • Parent commits 42b6802

Comments (0)

Files changed (3)

File sqlserver_ado/creation.py

         """
     
         if not self._test_database_create(settings):
-            print "Skipping Test DB destruction"    
+            if verbosity >= 1:
+                print "Skipping Test DB destruction"
+            return
 
         old_wrapper = self.connection
         old_wrapper.close()

File sqlserver_ado/dbapi.py

 from django.conf import settings
 from django.db.utils import IntegrityError as DjangoIntegrityError, \
     DatabaseError as DjangoDatabaseError
-from django.utils import timezone
+
+try:
+    from django.utils import timezone
+except ImportError:
+    # timezone added in Django 1.4
+    timezone = None
 
 import pythoncom
 import win32com.client
     dt = (datetime.datetime.fromordinal(day_count + _ordinal_1899_12_31) +
         datetime.timedelta(milliseconds=fraction_of_day * _milliseconds_per_day))
     
-    if settings.USE_TZ:
+    if timezone and getattr(settings, 'USE_TZ', False):
         dt = dt.replace(tzinfo=timezone.utc)
     return dt
 

File sqlserver_ado/operations.py

 import time
 from django.conf import settings
 from django.db.backends import BaseDatabaseOperations
-from django.utils import timezone
 
+try:
+    from django.utils import timezone
+except ImportError:
+    # timezone added in Django 1.4, use provided partial backport
+    import timezone
 
 class DatabaseOperations(BaseDatabaseOperations):
     compiler_module = "sqlserver_ado.compiler"
             return None
             
         if timezone.is_aware(value):
-            if settings.USE_TZ:
+            if getattr(settings, 'USE_TZ', False):
                 value = value.astimezone(timezone.utc).replace(tzinfo=None)
             else:
                 raise ValueError("SQL Server backend does not support timezone-aware datetimes.")
         the correct function names.
         """
         return True
+
+    def enable_identity_insert(self, table):
+        """
+        Backends can implement as needed to enable inserts in to
+        the identity column.
+        
+        Should return True if identity inserts have been enabled.
+        """
+        if table:
+            from django.db import connection
+            cursor = connection.cursor()
+            cursor.execute('SET IDENTITY_INSERT {0} ON'.format(
+                connection.ops.quote_name(table)
+            ))
+            return True
+        return False
+    
+    def disable_identity_insert(self, table):
+        """
+        Backends can implement as needed to disable inserts in to
+        the identity column.
+        
+        Should return True if identity inserts have been disabled.
+        """
+        if table:
+            from django.db import connection
+            cursor = connection.cursor()
+            cursor.execute('SET IDENTITY_INSERT {0} OFF'.format(
+                connection.ops.quote_name(table)
+            ))
+            return True
+        return False
+