Commits

Anonymous committed e48939c

timezone message

Comments (0)

Files changed (2)

sqlserver_ado/base.py

     
     ignores_nulls_in_unique_constraints = False
 
+    uses_savepoints = True
+
+    # Does the backend allow very long model names without error?
+    supports_long_model_names = False
 
 def is_ip_address(value):
     """

sqlserver_ado/operations.py

             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.")
+                raise ValueError("SQL Server backend does not support timezone-aware datetimes when USE_TZ is False.")
 
         # SQL Server 2005 doesn't support microseconds
         if self.is_sql2005():
         return value
     
     def value_to_db_time(self, value):
-        if not self.is_sql2005():
-            return value
+        if value is None:
+            return None
 
         if timezone.is_aware(value):
             raise ValueError("SQL Server backend does not support timezone-aware times.")
 
         # MS SQL 2005 doesn't support microseconds
-        #...but it also doesn't really suport bare times
-        if value is None:
-            return None
-        
-        return value.replace(microsecond=0)
+        #...but it also doesn't really support bare times
+        if not self.is_sql2005():
+            return value.replace(microsecond=0)
+        return value
 
     def value_to_db_decimal(self, value, max_digits, decimal_places):
         if value is None or value == '':
             return True
         return False
 
+    def last_executed_query(self, cursor, sql, params):
+        """
+        Returns a string of the query last executed by the given cursor, with
+        placeholders replaced with actual values.
+
+        `sql` is the raw query containing placeholders, and `params` is the
+        sequence of parameters. These are used by default, but this method
+        exists for database backends to provide a better implementation
+        according to their own quoting schemes.
+        """
+        return cursor.query
+
+    def savepoint_create_sql(self, sid):
+        return "SAVE TRANSACTION %s" % sid
+
+    def savepoint_commit_sql(self, sid):
+        return ""  # the savepoint becomes committed by committing the transaction
+
+    def savepoint_rollback_sql(self, sid):
+        return "ROLLBACK TRANSACTION %s" % sid