Commits

Michael Manfre committed 612cf9f

datetime.time values will convert to datetime.min + time going to the database and a datetime.time will be returned when reading from the database.

Comments (0)

Files changed (2)

sqlserver_ado/compiler.py

             internal_type = field.get_internal_type()
             if internal_type == 'DateField' and isinstance(value, datetime.datetime):
                 new_row.append(value.date())
+            elif internal_type == 'TimeField' and isinstance(value, datetime.datetime):
+                new_row.append(value.time())    
             else:
                 new_row.append(value)
         return new_row

sqlserver_ado/dbapi.py

             p.NumericScale = 0
             p.Precision = digit_count + exponent
 
+    elif isinstance(value, datetime.time):
+            p.Value = datetime.datetime(1,1,1, value.hour, value.minute, value.second)
     else:
         # For any other type, set the value and let pythoncom do the right thing.
         p.Value = value
             try:
                 _configure_parameter(p, value)
                 self.cmd.Parameters.Append(p)
-            except:
+            except Exception as e:
                 _message = u'Converting Parameter %s: %s, %s\n' %\
                     (p.Name, ado_type_name(p.Type), repr(value))